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

35 lines
918 B
CoffeeScript
Executable File

#! /usr/bin/env coffee
fs = require 'fs'
path = require 'path'
symLinks = {}
rdSync = (dpath, tree, name) ->
files = fs.readdirSync(dpath)
for file in files
# ignore non-essential directories / files
continue if file in ['.git', 'node_modules', 'bower_components', 'build'] or file[0] is '.'
fpath = dpath + '/' + file
try
# Avoid infinite loops.
lstat = fs.lstatSync(fpath)
if lstat.isSymbolicLink()
symLinks[lstat.dev] ?= {}
# Ignore if we've seen it before
continue if symLinks[lstat.dev][lstat.ino]?
symLinks[lstat.dev][lstat.ino] = 0
fstat = fs.statSync(fpath)
if fstat.isDirectory()
tree[file] = child = {}
rdSync(fpath, child, file)
else
tree[file] = null
catch e
# Ignore and move on.
return tree
fs_listing = rdSync(process.cwd(), {}, '/')
console.log(JSON.stringify(fs_listing))