Skip to content

Commit 027532e

Browse files
committed
Merge branch 'sm-worker-package-fetch' of github.com:seanmorris/emscripten into sm-worker-package-fetch
2 parents efaf744 + e2c4ea8 commit 027532e

File tree

7 files changed

+53
-45
lines changed

7 files changed

+53
-45
lines changed

ChangeLog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ to browse the changes between the tags.
1818

1919
See docs/process.md for more on how version tagging works.
2020

21-
3.1.67 (in development)
21+
3.1.68 (in development)
2222
-----------------------
23+
24+
3.1.67 - 09/17/24
25+
-----------------
2326
- Add option `nonnull<ret_val>()` to Embind to omit `| null` from TS definitions
2427
for functions that return pointers.
2528

emscripten-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.67-git
1+
3.1.68-git

src/audio_worklet.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,22 @@ class BootstrapMessages extends AudioWorkletProcessor {
168168
}
169169
#endif
170170
// Register a real AudioWorkletProcessor that will actually do audio processing.
171-
registerProcessor(d['_wpn'], createWasmAudioWorkletProcessor(d['audioParams']));
171+
// 'ap' being the audio params
172+
registerProcessor(d['_wpn'], createWasmAudioWorkletProcessor(d['ap']));
172173
#if WEBAUDIO_DEBUG
173-
console.log(`Registered a new WasmAudioWorkletProcessor "${d['_wpn']}" with AudioParams: ${d['audioParams']}`);
174+
console.log(`Registered a new WasmAudioWorkletProcessor "${d['_wpn']}" with AudioParams: ${d['ap']}`);
174175
#endif
175176
// Post a Wasm Call message back telling that we have now registered the
176-
// AudioWorkletProcessor class, and should trigger the user onSuccess
177-
// callback of the
178-
// emscripten_create_wasm_audio_worklet_processor_async() call.
179-
p.postMessage({'_wsc': d['callback'], 'x': [d['contextHandle'], 1/*EM_TRUE*/, d['userData']] }); // "WaSm Call"
180-
} else if (d['_wsc']) {
177+
// AudioWorkletProcessor, and should trigger the user onSuccess callback
178+
// of the emscripten_create_wasm_audio_worklet_processor_async() call.
179+
//
181180
// '_wsc' is short for 'wasm call', using an identifier that will never
182181
// conflict with user messages
182+
// 'cb' the callback function
183+
// 'ch' the context handle
184+
// 'ud' the passed user data
185+
p.postMessage({'_wsc': d['cb'], 'x': [d['ch'], 1/*EM_TRUE*/, d['ud']] });
186+
} else if (d['_wsc']) {
183187
Module['wasmTable'].get(d['_wsc'])(...d['x']);
184188
};
185189
}

src/library_noderawfs.js

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,27 @@ addToLibrary({
1010
if (!ENVIRONMENT_IS_NODE) {
1111
throw new Error("NODERAWFS is currently only supported on Node.js environment.")
1212
}
13-
// Use this to reference our in-memory filesystem
14-
var VFS = Object.assign({}, FS);
15-
// Override the init function with our own
16-
FS.init = NODERAWFS.init;`,
17-
$NODERAWFS: {
18-
init() {
19-
var _wrapNodeError = function(func) {
20-
return function(...args) {
21-
try {
22-
return func(...args)
23-
} catch (e) {
24-
if (e.code) {
25-
throw new FS.ErrnoError(ERRNO_CODES[e.code]);
26-
}
27-
throw e;
13+
var _wrapNodeError = function(func) {
14+
return function(...args) {
15+
try {
16+
return func(...args)
17+
} catch (e) {
18+
if (e.code) {
19+
throw new FS.ErrnoError(ERRNO_CODES[e.code]);
2820
}
21+
throw e;
2922
}
30-
};
31-
32-
// Wrap the whole in-memory filesystem API with
33-
// our Node.js based functions
34-
for (var _key in NODERAWFS) {
35-
/** @suppress {partialAlias} */
36-
FS[_key] = _wrapNodeError(NODERAWFS[_key]);
3723
}
38-
39-
// Setup the stdin, stdout and stderr devices
40-
FS.createStandardStreams();
41-
},
24+
};
25+
// Use this to reference our in-memory filesystem
26+
/** @suppress {partialAlias} */
27+
var VFS = Object.assign({}, FS);
28+
// Wrap the whole in-memory filesystem API with
29+
// our Node.js based functions
30+
for (var _key in NODERAWFS) {
31+
FS[_key] = _wrapNodeError(NODERAWFS[_key]);
32+
}`,
33+
$NODERAWFS: {
4234
lookup(parent, name) {
4335
#if ASSERTIONS
4436
assert(parent)

src/library_webaudio.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,12 @@ let LibraryWebAudio = {
122122
},
123123

124124
#if AUDIO_WORKLET
125+
// emscripten_start_wasm_audio_worklet_thread_async() doesn't use stackAlloc,
126+
// etc., but the created worklet does.
125127
emscripten_start_wasm_audio_worklet_thread_async__deps: [
126128
'$_wasmWorkersID',
127-
'$_EmAudioDispatchProcessorCallback'],
129+
'$_EmAudioDispatchProcessorCallback',
130+
'$stackAlloc', '$stackRestore', '$stackSave'],
128131
emscripten_start_wasm_audio_worklet_thread_async: (contextHandle, stackLowestAddress, stackSize, callback, userData) => {
129132

130133
#if ASSERTIONS
@@ -249,14 +252,15 @@ let LibraryWebAudio = {
249252
#endif
250253

251254
EmAudio[contextHandle].audioWorklet.bootstrapMessage.port.postMessage({
252-
// '_wpn' == 'Worklet Processor Name', use a deliberately mangled name so
253-
// that this field won't accidentally be mixed with user submitted
254-
// messages.
255-
_wpn: UTF8ToString(HEAPU32[options]),
256-
audioParams,
257-
contextHandle,
258-
callback,
259-
userData
255+
// Deliberately mangled and short names used here ('_wpn', the 'Worklet
256+
// Processor Name' used as a 'key' to verify the message type so as to
257+
// not get accidentally mixed with user submitted messages, the remainder
258+
// for space saving reasons, abbreviated from their variable names).
259+
'_wpn': UTF8ToString(HEAPU32[options]),
260+
'ap': audioParams,
261+
'ch': contextHandle,
262+
'cb': callback,
263+
'ud': userData
260264
});
261265
},
262266

src/runtime_shared.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
if (!shouldExport) {
1414
if (MODULARIZE && EXPORT_ALL) {
1515
shouldExport = true;
16-
} else if (AUDIO_WORKLET && (x == 'HEAP32' || x == 'HEAPU32')) {
16+
} else if (AUDIO_WORKLET && (x == 'HEAPU32' || x == 'HEAPF32')) {
1717
// Export to the AudioWorkletGlobalScope the needed variables to access
1818
// the heap. AudioWorkletGlobalScope is unable to access global JS vars
1919
// in the compiled main JS file.

test/test_other.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9753,6 +9753,11 @@ def test_noderawfs_access_abspath(self):
97539753
self.run_process([EMCC, 'access.c', '-sNODERAWFS'])
97549754
self.run_js('a.out.js', args=[os.path.abspath('foo')])
97559755

9756+
def test_noderawfs_readfile_prerun(self):
9757+
create_file('foo', 'bar')
9758+
self.add_pre_run("console.log(FS.readFile('foo', { encoding: 'utf8' }));")
9759+
self.do_runf('hello_world.c', 'bar', emcc_args=['-sNODERAWFS', '-sFORCE_FILESYSTEM'])
9760+
97569761
@disabled('https://github.com/nodejs/node/issues/18265')
97579762
def test_node_code_caching(self):
97589763
self.run_process([EMCC, test_file('hello_world.c'),

0 commit comments

Comments
 (0)