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

Try to compile to a lower target to support older browsers #17

Open
Jaifroid opened this issue Nov 27, 2022 · 7 comments · May be fixed by #18
Open

Try to compile to a lower target to support older browsers #17

Jaifroid opened this issue Nov 27, 2022 · 7 comments · May be fixed by #18
Assignees
Labels
bug Something isn't working build Code relating to building or publishing assets help wanted Extra attention is needed

Comments

@Jaifroid
Copy link
Collaborator

Jaifroid commented Nov 27, 2022

When we compiled XZ and ZSTD to WASM, we were also able to compile to ASM (the older, JavaScript-only version, which is quite fast and well optimized across most browsers). But even if we can only compile to WASM, the current build isn't working with some browsers that normally support WASM pretty well: notably UWP webview (and hence Edge Legacy), and Chrome for Android.

One possible solution might be to compile without pthreads: see emscripten-core/emscripten#13152 (comment).

But in principle, I don't see why we couldn't also try to produce ASM versions. It's normally just a change in the emcc commandline, but possibly can also be done with emmconfigure.

@Jaifroid Jaifroid added bug Something isn't working build Code relating to building or publishing assets labels Nov 27, 2022
@Jaifroid Jaifroid self-assigned this Nov 27, 2022
@Jaifroid Jaifroid linked a pull request Nov 28, 2022 that will close this issue
@Jaifroid
Copy link
Collaborator Author

I managed to compile an ASM version in #18. Testing.

@Jaifroid
Copy link
Collaborator Author

The ASM runs in Chrome on Windows. However, in UWP context I get 'Atomics' is not defined, for which error I get sent to https://emscripten.org/docs/porting/pthreads.html.

@Jaifroid
Copy link
Collaborator Author

We seem to be targeting only browsers that support Atomics, which is quite problematic as it cuts out all Chromium for Android, and requires flags to be enabled in some other browsers.

@Jaifroid
Copy link
Collaborator Author

Well, I've built an ASM version including MIN_IE_VERSION=11, and it still fails to load in browsers other than latest Chrome and Firefox, rejecting with Atomics not defined. It seems we have to find where Atomics are being included in the build chain and compile without them, if that's possible. In #18 I added to the Makefile --disable-pthreads in every emconfigure command, but zlib won't build with that option. The others all build fine with it, making me think that the problem is with zlib. But this is just a guess.

@Jaifroid
Copy link
Collaborator Author

I've tested fairly extensively in #18. With the POSIX threads requirement, which I can't seem to turn off especially in zlib, support is limited to Desktop Chrome/Edge and Firefox. Safari 16 fails, as does anything built off Chromium on Android. Chromium on Android seems to support Atomics, but in fact it doesn't appear to be able to transfer the ZIM archive reference into the Web worker, and as using a Worker is the only way in which we can currently support files > 2GB, we're stuck with it.

As it currently stands, the libzim build can't be used as the main ZIM reader, as it would cut off much of our user base. However, we can use it as an "add-on" for Full Text search in Chromium Desktop and Firefox. It seems a little odd to use it only for that, instead of a specific Xapian compilation, but the work of integrating the ZIM reader with Xapian has been done in libzim, and would have to be developed separately if we were to use a Xapian WASM only.

If anyone has a clue about how to get all the dependencies to compile single-threaded only, I'd be very grateful.

@Jaifroid
Copy link
Collaborator Author

Jaifroid commented Jan 2, 2023

I've opened an Issue at Emscripten, to see if I can get any help in compiling for browsers that don't support the JS Atomics object:

emscripten-core/emscripten#18453

@stale
Copy link

stale bot commented May 26, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

@stale stale bot added the stale label May 26, 2023
@Jaifroid Jaifroid removed the stale label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build Code relating to building or publishing assets help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant