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

MISC: Game crashes when loading via file:// #1778

Closed
catloversg opened this issue Nov 18, 2024 · 2 comments
Closed

MISC: Game crashes when loading via file:// #1778

catloversg opened this issue Nov 18, 2024 · 2 comments

Comments

@catloversg
Copy link
Contributor

catloversg commented Nov 18, 2024

Bitburner is a web application. A player can play it via:

[1] and [2] are the easiest ways to play this game, while [3] is only useful in some very special cases. After #1216 is merged, the game crashes when loading via file://. To enable TS and JSX support, we use swc-wasm, so we have to load a WASM file. However, WASM files cannot be loaded via file:// due to the same-origin policy.

Technically, I can refactor the codebase to make TS/JSX support optional and disable it when the game cannot load the required WASM file. However, I think it's not worth the effort. The refactoring will be complicated, and [3] is not a usual way to play our game. If a player (or contributor) needs to open the game in this way, they can use these workarounds:

  • Firefox: Set security.fileuri.strict_origin_policy in about:config page to true.
  • Chrome: Open Chrome with --allow-file-access-from-files.

Note that these workarounds have their own problems:

  • They change the security setting of the browser. Proceed at your own risk.
  • There is no guarantee that they will work in the future. In the past, Firefox used privacy.file_unique_origin. The new setting security.fileuri.strict_origin_policy may also be removed or changed in the future.

I created this issue as documentation for this new behavior change. If there are reports about this problem, we can link this issue.

@Snarling @d0sboots @gmcew FYI.

@catloversg catloversg closed this as not planned Won't fix, can't repro, duplicate, stale Nov 18, 2024
@catloversg catloversg changed the title MISC: Game crashes or cannot be loaded when loading via file:// MISC: Game crashes when loading via file:// Nov 18, 2024
@d0sboots
Copy link
Collaborator

Why is this not a problem for [2]? I'm guessing it's because of Electron's custom request handler, where we allow file:// access to the game's local resources, but lock it down otherwise.

Going forward, if we want to support [3] that may need to be the answer: start distributing the electron build instead of just the web files. File:// access is incredibly restricted (for good reasons), making it very hard to use any modern webpage without a server.

@catloversg
Copy link
Contributor Author

You are right. Our custom request handler handles file:// requests, so the Electron app does not have this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants