Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update egui to 0.25, wgpu to 0.19 and fix Firefox compatibility #88

Merged
merged 24 commits into from
Jan 31, 2024

Conversation

white-axe
Copy link
Collaborator

@white-axe white-axe commented Jan 13, 2024

Description
This pull request adds support for Firefox if the user installs an extension enabling the File System Access API, by fixing some minor unrelated compatibility issues. Safari is still not supported because I couldn't find an extension for Safari and it also doesn't support credentialless COEP.

This is the extension for Firefox: https://github.com/ichaoX/ext-file.

You should be using at least Firefox 119 (released 2023-10-24) because that's the first version that supports credentialless COEP by default. Firefox 104 (released 2022-08-23) and later support credentialless COEP as well, but it was just an origin trial back then and needs to be explicitly enabled in about:config (browser.tabs.remote.coep.credentialless).

Additionally, Firefox 114 (released 2023-06-06) or later is required for ES6 modules to work in web workers, so in summary the earliest version of Firefox supported by default is 119 and the earliest version supported with changes to about:config is 114. Theoretically we could support older versions of Firefox (104 or later) by refactoring the code to remove ES6 modules and then passing --target no-modules to wasm-bindgen, but I don't think this will be worth the effort given that we still need a lot more time to get Luminol to be a drop-in replacement for even RPG Maker XP.

Firefox's stable releases don't have WebGPU support at all yet, and Firefox Nightly only has support on the main thread and not in web workers where Luminol performs rendering, so I've changed the autobuild workflow for WebAssembly to also make a WebGL fallback build with the method I described in #52. For local testing, make sure to run Trunk with --features webgl.

The performance of the recursive directory search after loading projects is poor, but I have plans to fix this in another pull request. A lazy path cache was implemented in #90 to improve the performance of Luminol in Firefox.

I've also added checks (in assets/compat-test.js) for two things: secure context and Firefox private browsing. "Secure context" means either the website is being served over localhost or it's not localhost but being accessed through HTTPS rather than HTTP. We need a secure context because the File System Access API and a few other important APIs are not available outside of secure contexts. Firefox private browsing is checked for because service workers are not available in Firefox's private browsing mode and so coi-serviceworker.js won't be able to enable cross-origin isolation and allow us to use multithreading.

The crash reporter from #87 should also work in Firefox once this is merged, but for some reason it can only send reports to non-localhost URLs. If you try sending a report to localhost, the report will reach the server but Luminol will always say that the request failed.

Testing
Make sure to run Trunk with --features webgl and install the Firefox extension.

Open Luminol in Firefox 119 or later and check that the following things work. I've already tested all of these but it would be a good idea to test them again, especially on a non-Linux machine.

  • Opening projects using the Open Project button
  • Saving projects after modifying them
  • Opening recent projects from the recent projects menu
  • Creating archives
  • Extracting archives

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo build --release
  • If applicable, run trunk build --release

@white-axe white-axe requested a review from a team as a code owner January 13, 2024 18:53
@white-axe
Copy link
Collaborator Author

Guess what? wgpu finally has support for having both WebGPU and WebGL in the same binary, so we won't need to make a separate build for WebGPU and WebGL anymore! We still need to wait for gfx-rs/wgpu#5044 to reach a stable release of wgpu, though.

@Speak2Erase
Copy link
Member

Iirc wgpu plans to release 0.19 on the 17th, hopefully we don't need to wait long!

@white-axe white-axe mentioned this pull request Jan 17, 2024
5 tasks
@white-axe
Copy link
Collaborator Author

wgpu 0.19 released but it's not compatible with the version of winit that eframe 0.24 uses. I'll wait until catppuccin-egui upgrades to at least egui 0.25 and then upgrade egui, eframe and wgpu here.

@Speak2Erase
Copy link
Member

I'll get working on the luminol-preferences branch and merge that first so we don't need catppuccin-egui anymore

@white-axe white-axe marked this pull request as draft January 19, 2024 22:48
@white-axe
Copy link
Collaborator Author

catppuccin-egui updated to egui 0.25 today so I've updated everything and changed the web build to make one binary with both WebGPU and WebGL support.

wgpu 0.19 also comes with gfx-rs/wgpu#4607 which supposedly fixes the DX12 push constant bugs we'd experienced, so I've also removed the disabling of push constants on DX12. Needs testing on Windows with DX12 to see if it can run without crashing.

@white-axe white-axe marked this pull request as ready for review January 31, 2024 04:51
@white-axe white-axe added the dependencies Pull requests that update a dependency file label Jan 31, 2024
@white-axe white-axe changed the title Fix Firefox compatibility problems Update egui to 0.25, wgpu to 0.19 and fix Firefox compatibility Jan 31, 2024
This allows easily serving Luminol web builds under any path (e.g.
https://example.com/luminol/ instead of https://example.com/).
@white-axe white-axe merged commit 3b2e2c8 into Astrabit-ST:dev Jan 31, 2024
5 checks passed
@white-axe white-axe deleted the web-compat branch January 31, 2024 16:48
@white-axe
Copy link
Collaborator Author

white-axe commented Mar 10, 2024

Upon further testing, it seems the crash reporter actually can send crash reports to both localhost and non-localhost URLs without errors in Firefox. You just can't send crash reports anywhere while offline in Firefox, even to localhost, due to the bug mentioned in #111. I was probably testing sending to localhost while offline before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file webassembly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants