exokitxr / exokit-web

Exokit WebXR engine for the browser
70 stars 18 forks source link

SharedArrayBuffer is not defined - Firefox #1

Closed kwadroke closed 5 years ago

kwadroke commented 5 years ago

Error in Console: ReferenceError: SharedArrayBuffer is not defined in Mozilla Firefox 68.0.2 (Desktop)

Per Mozilla SharedArrayBuffer is disabled in Firefox due to Spectre, but, re-enabled in Chrome since ~v67 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer

I figure that the target would be Google Chrome based browsers, but, wanted to a report Firefox issue.

avaer commented 5 years ago

According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer, that standard feature needs to be enabled by the user in Firefox's flags for now.

RangerMauve commented 5 years ago

BTW, after enabling the flag I'm getting SyntaxError: import declarations may only appear at top level of a module WindowBase.js:11

avaer commented 5 years ago

@RangerMauve is there another flag for enabling that feature in Firefox? I know in Chrome you need to enable "Experimental Web Platform features" to get modules/import in Workers, which is how Exokit works.

That's not going to be a requirement long term since we'll just run exokit-web code through a bundler and there will be no more import. But the current state makes it more convenient to use raw import while still developing.

kwadroke commented 5 years ago

According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer, that standard feature needs to be enabled by the user in Firefox's flags for now.

The info for that was hidden without clicking on the flag under https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#Browser_compatibility

For future reference - javascript.options.shared_memory need to be enabled in about:config

BTW, after enabling the flag I'm getting SyntaxError: import declarations may only appear at top level of a module WindowBase.js:11

I see the same.

avaer commented 5 years ago

https://web.exokit.org does work for me in regular Chrome.

kwadroke commented 5 years ago

https://web.exokit.org does work for me in regular Chrome.

It does for me when I add the experimental web command line flag google-chrome --enable-experimental-web-platform-features http://web.exokit.org

I see this when I don't run with the flag: WindowVm.js:11 Uncaught TypeError: Failed to construct 'Worker': Module scripts are not supported on DedicatedWorker yet. You can try the feature with '--enable-experimental-web-platform-features' flag

Might be tricky to run this on an Oculus Quest.

avaer commented 5 years ago

Per https://github.com/exokitxr/exokit-web/issues/1#issuecomment-524941006, you don't need any flags if you bundle the code with something like parcel, which resolves all of the imports statically.

Additionally, not even this will be needed when Chrome implements the import spec.

kwadroke commented 5 years ago

Is https://web.exokit.org bundled with parcel, or is that for local only files? I get the same error via that URL with Firefox there as I am locally. I'm working on getting parcel installed, but currently throwing an error on my CentOS 7 box, so more work on my side.

avaer commented 5 years ago

Negative, it is not currently bundled, but that is the plan for this repo when we ship a distributable in (for example) dist/exokit.min.js. Setting that up would be a welcome PR!

kwadroke commented 5 years ago

Ok. I've got parcel to run, but, having mime-type issues. Once I get that fixed, will post results with Firefox.

avaer commented 5 years ago

Note that two builds would need to be made, one for the parent (index.js) and one for the worker (WindowBase.js).

Chrome is complaining about the latter.

avaer commented 5 years ago

Labeling this is wontfix for now. The plan is to wait for Firefox to fix their SharedArrayBuffer implementation.

RangerMauve commented 5 years ago

@kwadroke Was enabling the shared buffers flag all you needed to do to get it to load? I still had those uncaught exceptions from before in Nightly.

avaer commented 5 years ago

We aren't using import in Worker anymore if that's the question.

RangerMauve commented 5 years ago

Oh sweet. After pulling the latest master it seems to be working! :D :D

kwadroke commented 5 years ago

It's working pulling from master on FF 68.0.2 Desktop (non-VR mode) after enabling javascript.options.shared_memory without building. At least the page comes up without error.

Will test on 69 once I restart FF.

chrislatorres commented 5 years ago

Working for me on FF 70.0b3 (64-bit) and FF 69.0 (64-bit)

after javascript.options.shared_memory enabled

kwadroke commented 5 years ago

Tested on FF 69 Desktop with javascript.options.shared_memory and so far it works. Closing Issue. It would be nice not to have to set that feature in every FF browser, but, I understand why.

kwadroke commented 5 years ago

For historical/search purposes: SharedArrayBuffer work-around is no longer needed by Commit 643da0b (pull Request #47) .