tauri: Trying to check if an object is an instance of SharedArrayBuffer throws error.
Describe the bug During runtime Tauri interprets SharedArrayBuffer as a variable when checking instance types using instanceof. For example this code:
console.log({} instanceof SharedArrayBuffer);
would throw :
Unhandled Promise Rejection: ReferenceError: Can't find variable: SharedArrayBuffer
instead of printing false to the console.
To Reproduce
- Run the code
console.log({} instanceof SharedArrayBuffer); - Throws error
Expected behavior
Should just print false
Platform and Versions (please complete the following information):
OS: Ubuntu 20.10 Node: v15.3.0 NPM: 7.0.14 Rustc: 1.50.0
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 6
- Comments: 19 (15 by maintainers)
I just tested on Ubuntu 22.04 with
libwebkit2gtk-4.0-dev/jammy,now 2.36.0-2ubuntu1. Using the localhost plugin (https://github.com/tauri-apps/tauri/issues/3917#issuecomment-1104433755), I can getwindow.crossOriginIsolatedto betrue, butSharedArrayBufferis still not available.WebKit/WebKit#8578 (comment) describes the implementation and platform support surface attached to the merged changes that enable access to
SharedArrayBufferObjects docs usingAtomics.waitAsync()docs on the main thread running JavaScriptCore.Might be worth re-running tests on latest release of iOS, OSX and a linux build with updated WebKitGTK
This solution can be used on Windows though.
I still see
falseprinted to the console. I am on windows though. I will have to test it on my linux machine later.This is the app I’m using for testing: https://github.com/pwespi/tauri-app-shared-array-buffer (uses the localhost plugin).
The frontend part of it is deployed to https://tauri-app-shared-array-buffer.vercel.app/, such that it can also be used to test browsers.
Notable results:
SharedArrayBufferavailableSupporting
SharedArrayBufferwould unblock access to packages like:Does anyone have any updates or workarounds?
I guess that it was removed due to Spectre (note the deprecation of high-resolution timers too). We should probably nudge the webkit devs to look into re-enabling.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements
This is definitely upstream and not anything either Tauri nor WRY can do anything about. Sorry