I am trying to run mupdf built as web assembly in a webview on Android.

I have set the response headers correctly as far as I know, and this is illustrated by the fact that the web page using the web assembly works fine on desktop browsers and android browsers (including Chrome which uses a version of webview).

But when running a program of my own which uses a webview, the page when loaded gives a console message saying SharedArrayBuffer is not defined.

What I expect is that the webview in my program, when loading, should work the same as in the browsers. All other pages I use, with complex javascript, work the same way. But this one reaches the attempt to create a SharedArrayBuffer, and fails with an error in the console.

When I go to the page that tries to load the web assembly code, and which uses a Shared ArrayBuffer, I have checked and in every browser,

window.isSecureContext is true and window.crossOriginIsolated is true

however, in the webview in my program

window.isSecureContext is true BUT window.crossOriginIsolated is false

1

There are 1 best solutions below

2
On

I am having the exact same issue and there doesn't seem to be anything about this on the internet.

Webview (109.0.5414.117) doesn't seem to support cross-origin isolation, and my Xiaomi Redmi 7a Android 10 can't update to the newest version as of this writing (110.0.5481.64).

This is quite bad because there are a lot of phones that don't support newer versions of Webview and never will.

Here is the only discussion regarding this topic that I managed find: https://github.com/ionic-team/capacitor/issues/6182

On some platforms, Site Isolation is not available, due to implementation or resource constraints.