3845 Commits

Author SHA1 Message Date
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
366612fb82 Revert "Fix some string appending"
This reverts commit 65b9ea4e760ef2fd6c728222623c227e5f960a45.
2025-02-11 23:48:12 +01:00
LibretroAdmin
65b9ea4e76 Fix some string appending 2025-02-11 23:08:55 +01:00
Eric Warmenhoven
b0999db885
properly initialize variable (#17555) 2025-02-11 16:09:05 +01:00
LibretroAdmin
c57c4fbd1a Style nits 2025-02-10 13:59:25 +01:00
LibretroAdmin
72efcab3e7 Silence more warnings 2025-02-09 21:11:35 +01:00
LibretroAdmin
91aa8034b1 Style nits/conventions 2025-02-09 16:43:51 +01:00
LibretroAdmin
0be8fe8e3f Style nits 2025-02-09 16:07:15 +01:00
Rob Loach
7ba205ba34 common: Move audio_mixer_sound user_data to above the types union 2025-01-31 16:29:18 -05:00
Rob Loach
355b277c11
common: Add a user_data pointer to audio_mixer_sound (#17488) 2025-01-31 03:41:07 +01:00
LibretroAdmin
2870a0a8ad
Revert "Workerized emscripten retroarch (WIP) (#17484)" (#17492)
This reverts commit cacd5a9a234f3c9abc8d352f6fea19117e2e1a00.
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
Eric Warmenhoven
fd8ba559d7
net_http: fix memleak (#17487) 2025-01-30 04:06:59 +01:00
BinBashBanana
ed1810de86
Emscripten improvements (#17422) 2025-01-29 05:29:16 +01:00
Eric Warmenhoven
12f66bebb7
net_http: expire dns lookup failures more quickly (#17481) 2025-01-28 23:27:51 +01:00
Eric Warmenhoven
d00ee5a70b
net_http: handle redirects (#17482) 2025-01-28 23:27:28 +01:00
Eric Warmenhoven
d2eb49ccbc
net_http refactor (#17460)
* net_http: refactor net_http_new

The goal is to move calls to getaddrinfo() and connect() into
net_http_update(). This will make it possible for them to be replaced
with non-blocking alternatives later.

The net_http calling pattern right now allows callers to create the
http_connection_t, call net_http_new() which creates the http_t from
the http_connection_t, free the http_connection_t, and then start
calling net_http_update(). In order to preserve that, the http_t needs
to copy the values out of the http_connection_t on create. This also
preserves the http_connection_t values instead of freeing them, so the
connection would be able to be used later.

* net_http: implement dns cache

* net_http: separate out address resolution, connect, and request send

* net_http: perform getaddrinfo on separate thread

* net_http: implement basic connection pool

* net_http: refactor receive calls to read faster, do fewer reallocs

* net_http: build fix for platforms without SSL

* net_http: build fix for non-griffin builds

* net_http: build fix for non-threaded platforms
2025-01-23 01:29:47 +01:00
LibretroAdmin
b443d9974a Cleanup 2025-01-21 00:17:18 +01:00
LibretroAdmin
1ecd83b0ab Change returntype of random to size_t 2025-01-20 23:59:09 +01:00
sonninnos
391ba55b81
Add playlist random selector (#17441)
* Add playlist random selector

* Buildfix attempt

* ORBIS buildfix attempt
2025-01-20 18:25:41 +01:00
LibretroAdmin
a6c8c6c7ef Cleanups 2025-01-19 23:57:15 +01:00
LibretroAdmin
3549d8378c Style nits 2025-01-19 22:15:34 +01:00
LibretroAdmin
984d591573 Silence some warnings 2025-01-18 01:48:33 +01:00
LibretroAdmin
b211adaaca Function argument name standardization 2025-01-17 19:55:32 +01:00
LibretroAdmin
b47e09534c Less string copies 2025-01-17 13:10:17 +01:00
LibretroAdmin
1e83bfb971 Reduce char arrays 2025-01-17 12:55:45 +01:00
LibretroAdmin
31b7812720 Function argument name standardization 2025-01-17 04:16:12 +01:00
LibretroAdmin
a9b0e45013 (glslang_utill.c) One less string copy per iteration 2025-01-17 03:01:59 +01:00
LibretroAdmin
86c9a43b08 Use path_get_extension_mutable 2025-01-16 21:09:19 +01:00
LibretroAdmin
a5c9d9520f * Use fill_pathname_basedir where possible
* Move static variable to only function where it's used
* Change signature of file_path.c function
2025-01-15 22:17:59 +01:00
LibretroAdmin
b2072dd3be Use strldup where possible, avoid strcpy_literal 2025-01-15 16:36:49 +01:00
LibretroAdmin
9da7af46c3 len variable/argument name standardization 2025-01-15 16:04:25 +01:00
LibretroAdmin
047e04ed3e Standardize local len variable naming conventions 2025-01-15 15:00:12 +01:00
LibretroAdmin
47d888364d Standardize len variables - argument should always be named 'len',
while local len variables should have '_' prefix
2025-01-13 21:53:49 +01:00
LibretroAdmin
3c3611af6f Resync libretro-common 2025-01-13 15:37:59 +01:00
Eric Warmenhoven
fcda24be29
Files in archives should always be marked as such (#17390) 2025-01-11 02:51:04 +01:00
LibretroAdmin
fc48ecaa1d Local 'len' variables need to prefixed with '_', inner-loop len
variables need to be prefixed with '__'
2025-01-07 02:57:24 +01:00
LibretroAdmin
a98ab483cb Restore archive_file_7z.c 2025-01-07 02:22:57 +01:00
Eric Warmenhoven
53d9452439
Change config_get_path/array return back to bool (#17333) 2025-01-02 14:35:33 +01:00
LibretroAdmin
1e656261b0 Local len variables need to have '_' prefix 2024-12-30 14:03:58 +01:00
Viačasłaŭ
945d3ebc5f
Fix memleak (#17307) 2024-12-29 18:57:45 +01:00
LibretroAdmin
4297f02544 Use returntype for fill_pathname_basedir 2024-12-28 23:11:24 +01:00
Eric Warmenhoven
ef1b325978
Change return types for some path functions to size_t (#17303) 2024-12-28 22:26:30 +01:00
LibretroAdmin
9d15900979 Small cleanups: * Prevent some unneccessary strlcpy calls and intermediary string copies * Name local length variables for strings '_len', parameter/argument 'len' 2024-12-28 22:22:07 +01:00
LibretroAdmin
18c85b5ccd Cleanups -
* Less string copies
* Some general cleanups
* Add extra param to runloop_message_queue_push so we can pass size_t
of the message
* Consistent conventions for local variable usage for certain things
2024-12-27 15:13:45 +01:00
LibretroAdmin
ed58e4a8d8 Conventionalize len variables:
* In function arguments, use 'size_t len'
* Inside the function, use '_len'
* If you need a seciondary len variable inside the function, use '__len'
2024-12-27 05:51:33 +01:00
libretroadmin
51e706007b String handling cleanups 2024-12-25 19:06:04 +01:00
libretroadmin
83a187784a Remove dependency on strlcpy for rjson.c 2024-12-24 21:09:15 +01:00
libretroadmin
8074a833aa Cleanups/less string copies and indirection 2024-12-24 21:07:31 +01:00
libretroadmin
279270ae5f string_list_join_concat_special - specialized version without bounds
check
2024-12-24 06:14:26 +01:00