Commit Graph

78 Commits

Author SHA1 Message Date
BinBashBanana 05cefc9a4d AudioWorklet driver, misc. emscripten fixes 2025-03-28 19:41:40 -07:00
BinBashBanana c672730259 address issues 2025-03-06 15:38:40 -08:00
BinBashBanana f6eb1ed5c5 Threaded emscripten improvements 2025-03-05 10:39:43 -08:00
Joe Osborn c413bcc626
Threaded emscripten fixes (#17614)
* Actually read CLI args in emscripten

* Fix fetchfs manifest parsing, increase download chunk size

The chunk size should probably be made a parameter in the future.  The
larger chunk size trades longer hitches for fewer hitches.

* Add exec command driver and API functions for emscripten.

Under WASMFS, stdin/stdout can't be customized the way they can with
the JS FS implementation.  Also, this approach frees up stdin/stdout
and simplifies interaction with the command interface for web embedders.

* fixup upload paths, show use of new emscripten cmd interface

* Add JS library function names to EXPORTS as well as EXPORTED_FUNCTIONS for older emsdk versions
2025-02-24 09:25:05 -08:00
Joe Osborn 56014a27d6
Enable pthreads on Emscripten (#17586)
* workerized RA

* Workerized (non-async) web player, using OPFS

This patch eliminates the need for asyncify and uses modern filesystem
APIs instead of the deprecated, unmaintained BrowserFS.

This is a WIP patch because it won't fully work until these two
Emscripten PRs land and are released:

https://github.com/emscripten-core/emscripten/pull/23518
https://github.com/emscripten-core/emscripten/pull/23021

The former fixes an offscreen canvas context recreation bug, and the
latter adds an equivalent to BrowserFS's XHR filesystem (but without
the hazardous running-XHR-on-the-main-thread problem).

The biggest issue is that local storage of users who were using the
old version of the webplayer will be gone when they switch to the new
webplayer.  I don't have a good story for converting the old BrowserFS
IDBFS contents into the new OPFS filesystem (the move is worth doing
because OPFS supports seeking and reading only bits of a file, and
because BrowserFS is dead).

I've kept around the old libretro webplayer under
pkg/emscripten/libretro-classic, and with these make flags you can
build a non-workerized RA that uses asyncify to sleep as before:

make -f Makefile.emscripten libretro=$CORE HAVE_WORKER=0 HAVE_WASMFS=0 PTHREAD=0 HAVE_AL=1

I also moved the default directory for core content on emscripten to
not be a subdirectory of the local filesystem mount, because it's
confusing to have a subdirectory that's lazily fetched and not
mirrored to the local storage.  I think it won't impact existing users
of the classic web player because they already have a retroarch.cfg in
place.

* Get fetchfs working without manifest support

* makefile fixes

* fix scaling, remove zip dependency

* Support asset/cheats/etc downloaders for emscripten

- Add http transfer support for emscripten
  - At the task_http level, not the net_http level --- so no netplay
    or webdav.
- Change default paths to be more like other platforms
- Gives us smaller bundles and a faster boot time
- Had to work around a task queue bug on Emscripten
  - I made the smallest possible change to do it, but it may be better
    to fix in rthread.c

* Load an emscripten file_packager package on first run

If no ozone assets are present, load a libretro_minimal package
created using Emscripten's built-in file packager.

* updated readme, removed indexer from wasmfs libretro-web

* Put back zip dependency, load asset bundle into opfs on first run

* fix upload path

* Remove unused function

* easy testing setup for two multithreaded conditions

1. make PROXY_TO_PTHREAD=1 (slower)
2. make PROXY_TO_PTHREAD=0 (bad audio, because doesn't sleep in
openal.c)

* Remove condition on sleep in openal

also make input_driver check existence of drv->axis, drv->button
before calling them.

* Fix resizing under EGL

* Don't force config file path on emscripten

* Add time.h include to netplay, default HAVE_NETPLAYDISCOVERY to 0

* Remove nearly all proxied joypad calls under emscripten

* Fix file uploads under firefox

* Fix safari API uses, but Safari still hangs in OPFS filesystem mount

I think this can be fixed by moving the backend creation off the main
thread.

* Move filesystem init into emscripten C entry point

* Setup filesystems off of main thread

* re-set default player to async

Also improve Safari compatibility under proxy-to-pthread condition

* Safari upload file fixes

* Remove some excess prints

* Fix typo
2025-02-20 00:59:25 +01:00
BinBashBanana ed1810de86
Emscripten improvements (#17422) 2025-01-29 05:29:16 +01:00
Joe Osborn 862bebf687
(Emscripten) Modularize the JavaScript and clean up the web build (#15688)
* Increase emscripten stack size and decrease path size to fix emscripten builds broken since de45fc2

* use modularize flags for better-behaved javascript output

* makefile and loader changes

* use specialHTMLTargets to support modular access to canvas

* bind key events to canvas, not document

This way focus means focus and we can have multiple RA instances in
one page.

* Work around an emscripten bug in strict mode

* (Emscripten) Use console.error() for error messages

* increase asyncify stack size

* Fix `-lm` flag-related compile warnings in emscripten

---------

Co-authored-by: Rob Loach <robloach@gmail.com>
2023-11-02 13:25:50 -07:00
Ethan O'Brien 58aafeec78 Fix RWebAudioInit race condition 2023-07-02 05:47:13 +02:00
Ethan O'Brien 7ac3dcd5fe change blocking conditions 2023-07-01 19:22:37 +02:00
Ethan O'Brien 88778bc137 Fix rwebaudio bug 2023-07-01 19:22:37 +02:00
SimpleTease bb6a680890
Emscripten: remove unused dependency (buildfix) 2020-12-18 03:40:18 +00:00
Toad King 618da66073 emscripten: add hack to prevent ERRNO_CODES from being optimized away 2019-08-07 22:07:09 -05:00
orbea 28ff4b391a Clean up white space. 2019-02-03 16:00:50 -08:00
Rob Loach cb3ab8b12e
emscripten: Use argument list for Module.print 2018-01-15 10:06:06 -05:00
Rob Loach 2f6297838e
emscripten: Remove output textarea
This removes the output textarea as we're using the console now.
2018-01-15 10:03:50 -05:00
Toad King 0256156a6b fix rwebaudio time drift
fixes audio getting stuck in an always fast state
2018-01-15 03:08:30 -06:00
Toad King 6f77859eed fixes to rwebaudio
it should no longer mark buffers for clear if they're still being filled
report correct total buffer size to help resampler
2018-01-14 22:56:53 -06:00
Toad King 7b3554fd3c fix crash in cores than send audio early 2018-01-14 20:46:08 -06:00
Toad King 1e212b4248 use emscripten HTML5 API for keyboard events instead of old JS library 2018-01-13 17:56:00 -06:00
Shane Mouton cf81ddcb4e Audio Performance Change
changed bufferSource variable to constant...This fixes the constant sound popping in Safari.
2017-09-26 20:53:02 -04:00
radius d3fa4535fc move these files over to the package dir 2016-08-28 19:09:55 -05:00
Andrés a2529620ad Merge pull request #3401 from RobLoach/tweaks
[Emscripten] Add design tweaks to the player
2016-08-17 14:44:55 -05:00
Rob Loach b20c843fa8
[Emscripten] Add design tweaks to the player 2016-08-17 15:43:35 -04:00
Rob Loach edb0e974d7 [Emscripten] Add some spacing above Start controls 2016-08-17 15:25:28 -04:00
Andrés 2723fe59a0 Merge pull request #3398 from RobLoach/patch-3
[Emscripten] Clean up the log textarea
2016-08-17 13:54:12 -05:00
Rob Loach 53ccbcc27a [Emscripten] Use the Bootstrap control for the log 2016-08-17 14:23:24 -04:00
Rob Loach dd8b19578b [Emscripten] Fix the CSS styling for the log 2016-08-17 14:22:21 -04:00
Rob Loach 60eddd189d [Emscripten] Improve the textarea styling 2016-08-17 14:17:26 -04:00
Rob Loach b7efb36099 [Emscripten] Center-align and darken the player 2016-08-17 14:11:48 -04:00
Rob Loach 6db5a423fa Update webplayer.js 2016-08-17 13:52:39 -04:00
Rob Loach 7602ce5bc9
[Emscripten] Fix disabling the vsync 2016-08-17 13:50:43 -04:00
Rob Loach 01665b5387
Add Tether for Bootstrap support 2016-08-17 02:13:51 -04:00
Rob Loach 2826524685
Add Bootstrap styles to emscripten 2016-08-17 02:11:26 -04:00
Andrés e8ca9eb623 Merge pull request #3390 from RobLoach/emscripten
Move emscripten JS/CSS to split files
2016-08-16 23:54:23 -05:00
Rob Loach 361949e89a
Add JS/CSS documentation 2016-08-16 23:35:25 -04:00
Rob Loach 6dfb76b669
Move emscripten JS/CSS to split files 2016-08-16 23:32:45 -04:00
Rob Loach 6ac4be7a73 Remove browserfs.min.js because it's not used
We are using browserfs.js, but not touching the minified version of it.
2016-08-16 23:10:28 -04:00
radius 62281f88ac this should go too 2016-08-04 01:10:10 -05:00
radius 93bf615267 remove old incomplete templates 2016-08-04 01:09:43 -05:00
radius 7fcee63d02 syncing the rootfs to dropbox works now 2016-08-04 01:09:43 -05:00
radius 664d37f943 initial emscripten dosbox integration 2016-08-03 20:25:20 -05:00
radius 0cf79af646 allow loading persistent content in webplayer 2016-08-03 01:20:35 -05:00
radius 6c96adc843 add a different template for localstorage 2016-08-02 23:07:16 -05:00
radius 0625db8d6d update browserfs 2016-08-02 23:04:01 -05:00
radius df9f33a7d7 remove some more cruft 2016-08-02 19:52:55 -05:00
radius c3c03d4e3c fix labels 2016-08-02 19:38:46 -05:00
radius ce7ba91411 simplify template 2016-08-02 19:37:15 -05:00
dalter 0026a5d08e Fix Audio Driver (Emscripten)
Fix sound crack in Fierfox, fix core frozen when load rom
2016-08-02 20:53:23 +03:00
Twinaphex 3def2655a2 Merge pull request #3305 from dalter/patch-4
Add SDL2 option
2016-07-31 21:14:45 +02:00
Twinaphex 2c06de9ae2 Merge pull request #3306 from dalter/patch-5
Add SDL2 option
2016-07-31 21:14:27 +02:00