Emscripten integration rewrite by RReverser · Pull Request #10 · mame/xterm-pty (original) (raw)
Apologies in advance, this is a large rewrite and might be hard to review as a diff rather than as just new code.
What this does:
- Switches off-main-thread proxying to the native
-s PROXY_TO_PTHREADfeature instead of custom worker, which allows to still run apps off the main thread but with support for Emscripten's functions that expect to be able to use at least proxying to access main thread. - Adds separate
-s ASYNCIFYmode, which allows to run application completely on the main thread. (I added some fixes to Asyncify <> JS library integration upstream that this depends on) - Adds support for signals (implemented default signal handlers upstream that this depends on), so termination and resizing etc are correctly forwarded.
- Rewrites integration itself to be just a
--js-library. It's currently messy because of the code that needs to do different proxying / waiting depending on execution mode. I have some ideas on how this could be improved from Emscripten side, but it's not a quick thing so for now bunch of#ifwill have to do. - Updated all demos.
- Updated docs.
Some extra refactoring changes I found helpful but don't have to be strictly part of this PR:
- Formatted build scripts.
- Made all build scripts executable.
- Made all demos build with
-Os. - Switched manual passing of compiler and other tools to
emconfigurewrapper instead. - Split out ncurses filesystem data from vim data so that it can be loaded separately.
Some notes:
- Due to mentioned fixes, this requires Emscripten 3.1.47.
- I left the old integration just in case under
src/client-serverif there are non-Emscripten uses for it, but it's now excluded from the bundle as it's no longer strictly necessary.
As a performance taster, here's the Sloane demo built using previous integration (but with added -Os for fair comparison):
vs new integration using -s PROXY_TO_PTHREAD:
Now it runs about as fast as in my native terminal!
All the other demos use Asyncify, but this one uses proxying mode for reasons explained in new docs.
Fixes mame#5.