UnrealEngineHTML5 / Documentation

540 stars 183 forks source link

"Uncaught ReferenceError: SharedArrayBuffer is not defined" on Chrome/Opera/Firefox #110

Open Lansselot opened 3 years ago

Lansselot commented 3 years ago

I build the default ue4 project SharedArrayBuffer image

POTKIRLAND commented 3 years ago

same thing is happening to me i tried adding

in my .html but that brings up BadMemory Error and i cant pass that... someone please help :((

doing this also results in errors

requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag

and

Uncaught (in promise) TypeError: runDependencyTracking is undefined

Lansselot commented 3 years ago

BadMemory Error

I also got this error after adding this script

SaurabhKumbhar24 commented 3 years ago

Got the same error

nicohakenes commented 2 years ago

I have the same error. Has anyone found a solution?

nicohakenes commented 2 years ago

Hey Guys,

it works for me when I set "--js-flags=--experimental-wasm-threads --enable-features=WebAssembly,SharedArrayBuffer" as flags before launching chrome. You can do this by doing a right-click on your desktop shortcut and add the quoted flags right after your defined target.

annachka commented 2 years ago

Here's another thing you can try to get it to load in any Chrome browser: https://developer.chrome.com/blog/enabling-shared-array-buffer/#origin-trial

This is the full solution, though: https://web.dev/coop-coep/

You could cross-origin-isolate your pages (requires sending an http header) or get an exception token for now.

(The origin trial worked for me with the token in a meta tag inside the main page, in Chrome).

kakarotdrv commented 2 years ago

--js-flags=--experimental-wasm-threads --enable-features=WebAssembly,SharedArrayBuffer

any Idea where exactly this needs to be added ?

DrRaedAbbas commented 1 year ago

Hello guys, I'm not a js developer but Unreal dev. I've exported my game to htmls and got the same error as described above.

Uncaught TypeError: Failed to execute 'send' on 'XMLHttpRequest': The provided ArrayBufferView value must not be shared.
NOTE: attempting to flush cache and force reload...
Please standby...

I've added --js-flags=--experimental-wasm-threads --enable-features=WebAssembly,SharedArrayBuffer to my Chrome but no luck. Anyone can help me getting my game to run please?

RedNicStone commented 1 year ago

Hello guys, I'm not a js developer but Unreal dev. I've exported my game to htmls and got the same error as described above.

Uncaught TypeError: Failed to execute 'send' on 'XMLHttpRequest': The provided ArrayBufferView value must not be shared.
NOTE: attempting to flush cache and force reload...
Please standby...

I've added --js-flags=--experimental-wasm-threads --enable-features=WebAssembly,SharedArrayBuffer to my Chrome but no luck. Anyone can help me getting my game to run please?

After some quick testing it looks like this it is still possible to override the SharedArrayBuffer behaviour of Chrome using the provided command and run a demo deployment that way. However this is nowhere near a good solution since this could possibly open up a client to the 'Spectre' vulnerability. It would be better to use COOP and COEP to isolate the content, which can be done easily by adding the corresponding key-value pairs to the HTTP header. Or if possible change the emscripten configuration to not generate code that uses the SAB feature. Disabling pthreads could also be a quick and dirty fix that should work on any web client. In the editor this can be done by navigating into Edit -> Project Settings -> Platforms -> HTML5 and unchecking Multithreading support. However, at least for me, this causes emscripten to fail when linking atomics due to a missing --shared-memory flag. Enabling this flag may explicitly allow the use of SharedArrayBuffers, so this might not be a solution.

Also, and unreal developer is not the same as a developer using unreal, this could be misleading.

RedNicStone commented 1 year ago

@DjWilly After some more testing I have confirmed that enabling COOP and COEP does work. However in order to run the application all remote references in the HTML must be changed to local ones, otherwise the resource request will be denied by the client. The easiest way to do this would be by just having a local duplicate of the reference on the server, another way would be to configure the server to resolve the request locally.

DrRaedAbbas commented 1 year ago

@RedNicStone Thank you for the testing and solution. I'll pass these to a web developer and see if they can solve it. I was hoping for add this command here and untick this and that. But since it's a lot more work involved it's better to let he who knows to handle it. Thanks alot again :)

Mootbing commented 1 year ago

@DjWilly After some more testing I have confirmed that enabling COOP and COEP does work. However in order to run the application all remote references in the HTML must be changed to local ones, otherwise the resource request will be denied by the client. The easiest way to do this would be by just having a local duplicate of the reference on the server, another way would be to configure the server to resolve the request locally.

how did you end up fixing it?