Commit Graph

33 Commits

Author SHA1 Message Date
BinBashBanana 2d3c18e48d Emscripten improvements pt. 4 2025-05-08 11:01:43 -07:00
BinBashBanana f6eb1ed5c5 Threaded emscripten improvements 2025-03-05 10:39:43 -08:00
Joseph C. Osborn c29cd046d0 Fixes asset paths/double bundle path for web player 2025-02-28 18:44:31 +01: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
LibretroAdmin 2870a0a8ad
Revert "Workerized emscripten retroarch (WIP) (#17484)" (#17492)
This reverts commit cacd5a9a23.
2025-01-30 21:35:58 +01:00
Joe Osborn cacd5a9a23
Workerized emscripten retroarch (WIP) (#17484)
* 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
2025-01-30 19:58:18 +01:00
BinBashBanana ed1810de86
Emscripten improvements (#17422) 2025-01-29 05:29:16 +01:00
zoltanvb 864ad02177
Quickfix: asset size has exceeded 4x30 MB, so now there are 5 chunks. (#17334) 2025-01-02 19:31:35 +01:00
Joe Osborn 0f4166a59f
Use ZipFS for web player asset bundle (#15924)
* wip

* fix mount path

* Fix path for zip bundle

* fix case where idbfs sets up correctly and filesystem initializes too early

* Use partfiles to keep each zip small

* use bufferview slices instead of resize to support firefox
2023-11-17 11:25:45 -08: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
Joe Osborn e1afca5392
add command and stdin_cmd features to emscripten RA. update libretro.js to show how commands could be sent over emscripten stdin. (#15017)
Co-authored-by: Joseph C. Osborn <jcoa2018@pomona.edu>
2023-02-24 22:06:04 +01:00
Ryan Kuba 1fc6f759c5
tweak to ensure that current versions of emsdk do not break the web player (#13310) 2021-12-03 16:20:12 +01:00
Neil Barkhina 8590e0e3fe
Fixed web player bug with filesystem and runtime 2021-08-22 20:08:05 -04:00
Brad 54a166a360
Allows hosting in a subfolder instead of only root
Paths starting with slashes look in the root of a site, and these asset folders should generally be beside this .js + index.html...
This simple change was all that was needed to allow hosting in a subfolder of a site, and is not a breaking change unless someone has the asset folders elsewhere, which would be a breaking change on their part anyway.
2021-02-14 19:47:01 -06:00
Stevoisiak f4f339c4d5
Remove unnecessary escape character
http://eslint.org/docs/rules/no-useless-escape
2019-12-31 12:13:40 -05:00
twinaphex 3619fae2d9 (LGTM) Silence some warnings 2019-04-13 02:15:26 +02:00
Toad King 78a3d0f828 Merge branch 'master' into more-emscripten-fixes 2018-01-15 04:09:26 -06:00
Rob Loach 443262a9cd
emscripten: Allow hiding the top menu 2018-01-14 23:57:53 -05:00
radius d7168584a2 cut down duplication 2018-01-14 22:43:49 -05:00
radius 346d9480f7 remove dropbox 2018-01-14 22:31:30 -05:00
Toad King 2df70cce17 make retroarch logs log to web console instead of textbox 2018-01-14 21:18:30 -06:00
Toad King a682ccd8e8 fix menu button 2018-01-14 21:02:59 -06:00
Brad Parker 8f7810d921 emscripten: only fire keyup once, and don't wait so long to do so (libretro.js) 2017-12-08 18:15:22 -05:00
Rob Loach d386f63525
[Emscripten] Add Tooltips to the buttons 2016-12-03 11:44:26 -05:00
radius 50539d58df allow cleaning up idbfs 2016-11-21 20:58:45 -05:00
radius 4e33f25328 (ems) useless CDN is useless 2016-09-29 08:49:31 -05:00
radius c790f452e7 (ems) update template, don't enable run button till idbfs is synced 2016-09-24 22:32:47 -05:00
radius e48cd885f9 (ems) update webplayer template too 2016-09-24 17:30:03 -05:00
radius 29e354a3c6 (ems) template cleanups 2016-09-17 15:13:47 -05:00
radius 356c17678e (ems) add button to clean local storage 2016-09-17 12:37:42 -05:00
radius 6f195ddc6d (ems) template cleanup 2016-09-17 02:05:49 -05:00
radius 0515e9f753 (ems) remove some unused code 2016-09-17 02:01:13 -05:00
fr500 f4e35e3cdf (ems) reorganize templates 2016-09-15 18:18:26 -05:00