diff --git a/ChangeLog.md b/ChangeLog.md index 98388522f00d8..fc00bd3a392e9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works. 5.0.1 (in development) ---------------------- +- The (undocumented) Module.requestAnimationFrame, Module.pauseMainLoop and + Module.resumeMainLoop methods are no longer exported by default but must + be added to `-sEXPORTED_RUNTIME_METHODS`. () - `logReadFiles` was removed from the default `INCOMING_MODULE_JS_API` list. To use this feature you now need to explictly add `logReadFiles` to `INCOMING_MODULE_JS_API`. (#26190); diff --git a/src/lib/libeventloop.js b/src/lib/libeventloop.js index ad59b926208bf..d5138e4cbdbc0 100644 --- a/src/lib/libeventloop.js +++ b/src/lib/libeventloop.js @@ -191,13 +191,20 @@ LibraryJSEventLoop = { typeof MainLoop != 'undefined' && MainLoop.preMainLoop.push(f); }, + $requestAnimationFrame__docs: ` + /** + * @suppress {duplicate, checkTypes} + */`, + $requestAnimationFrame__deps: ['$MainLoop'], + $requestAnimationFrame: 'MainLoop.requestAnimationFrame', + $pauseMainLoop__deps: ['$MainLoop'], + $pauseMainLoop: 'MainLoop.pause', + $resumeMainLoop__deps: ['$MainLoop'], + $resumeMainLoop: 'MainLoop.resume', + $MainLoop__internal: true, $MainLoop__deps: ['$setMainLoop', '$callUserCallback', 'emscripten_set_main_loop_timing'], - $MainLoop__postset: ` - Module['requestAnimationFrame'] = MainLoop.requestAnimationFrame; - Module['pauseMainLoop'] = MainLoop.pause; - Module['resumeMainLoop'] = MainLoop.resume; - MainLoop.init();`, + $MainLoop__postset: `MainLoop.init();`, $MainLoop: { running: false, scheduler: null, diff --git a/test/codesize/test_codesize_hello_O0.json b/test/codesize/test_codesize_hello_O0.json index c88041660275d..0795ad6eb6325 100644 --- a/test/codesize/test_codesize_hello_O0.json +++ b/test/codesize/test_codesize_hello_O0.json @@ -1,10 +1,10 @@ { - "a.out.js": 24268, - "a.out.js.gz": 8718, + "a.out.js": 24319, + "a.out.js.gz": 8732, "a.out.nodebug.wasm": 15138, "a.out.nodebug.wasm.gz": 7455, - "total": 39406, - "total_gz": 16173, + "total": 39457, + "total_gz": 16187, "sent": [ "fd_write" ], diff --git a/test/codesize/test_codesize_hello_dylink_all.json b/test/codesize/test_codesize_hello_dylink_all.json index 905c54ed8db4b..9c8725344b43c 100644 --- a/test/codesize/test_codesize_hello_dylink_all.json +++ b/test/codesize/test_codesize_hello_dylink_all.json @@ -1,7 +1,7 @@ { - "a.out.js": 244700, + "a.out.js": 244558, "a.out.nodebug.wasm": 577696, - "total": 822396, + "total": 822254, "sent": [ "IMG_Init", "IMG_Load", diff --git a/test/codesize/test_codesize_minimal_O0.expected.js b/test/codesize/test_codesize_minimal_O0.expected.js index 687f2a57de237..fdce987280dad 100644 --- a/test/codesize/test_codesize_minimal_O0.expected.js +++ b/test/codesize/test_codesize_minimal_O0.expected.js @@ -1112,6 +1112,9 @@ missingLibrarySymbols.forEach(missingLibrarySymbol) 'emSetImmediate', 'emClearImmediate_deps', 'emClearImmediate', + 'requestAnimationFrame', + 'pauseMainLoop', + 'resumeMainLoop', 'promiseMap', 'Browser', 'requestFullscreen', diff --git a/test/codesize/test_codesize_minimal_O0.json b/test/codesize/test_codesize_minimal_O0.json index 64dd7944fbd5b..4b221c98fe2a2 100644 --- a/test/codesize/test_codesize_minimal_O0.json +++ b/test/codesize/test_codesize_minimal_O0.json @@ -1,10 +1,10 @@ { - "a.out.js": 19498, - "a.out.js.gz": 7013, + "a.out.js": 19549, + "a.out.js.gz": 7027, "a.out.nodebug.wasm": 1136, "a.out.nodebug.wasm.gz": 656, - "total": 20634, - "total_gz": 7669, + "total": 20685, + "total_gz": 7683, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_unoptimized_code_size.json b/test/codesize/test_unoptimized_code_size.json index 27350191fb96c..4eec3794642ec 100644 --- a/test/codesize/test_unoptimized_code_size.json +++ b/test/codesize/test_unoptimized_code_size.json @@ -1,16 +1,16 @@ { - "hello_world.js": 56965, - "hello_world.js.gz": 17729, + "hello_world.js": 57031, + "hello_world.js.gz": 17743, "hello_world.wasm": 15138, "hello_world.wasm.gz": 7455, "no_asserts.js": 26576, "no_asserts.js.gz": 8881, "no_asserts.wasm": 12187, "no_asserts.wasm.gz": 5984, - "strict.js": 54881, - "strict.js.gz": 17045, + "strict.js": 54947, + "strict.js.gz": 17060, "strict.wasm": 15138, "strict.wasm.gz": 7450, - "total": 180885, - "total_gz": 64544 + "total": 181017, + "total_gz": 64573 } diff --git a/test/test_other.py b/test/test_other.py index 1801350fb505d..0706f6d52ba8f 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -15438,3 +15438,19 @@ def test_logReadFiles(self): create_file('pre.js', 'Module.logReadFiles = 1;') output = self.do_runf('checksummer.c', args=['test.txt'], cflags=['--pre-js=pre.js']) self.assertContained('read file: /test.txt', output) + + def test_request_animation_frame(self): + create_file('test.c', r''' + #include + #include + + int main() { + EM_ASM({ + Module.requestAnimationFrame(() => console.log('got RAF')); + }); + printf("done\n"); + } + ''') + self.do_runf('test.c', "Aborted('requestAnimationFrame' was not exported", assert_returncode=NON_ZERO) + # Once added to EXPORTED_RUNTIME_METHODS it should be callable. + self.do_runf('test.c', "done\ngot RAF\n", cflags=['-sEXPORTED_RUNTIME_METHODS=requestAnimationFrame'])