-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle WindowShouldClose
using asyncify
#25
Conversation
- uses `asyncify-wasm` by GoogleChromeLabs - makes raylib.js an ES6 Module - allows 1:1 mapping from native to web - move `onchange` from index.html select box due to ES6 modules
- explicitly list imported async functions
- apparently, this is not the complete core_input_mouse example (as the name suggests)
- Asyncify requires `memcpy` / `memset` to copy arrays - somehow does not work - Make arrays static for now
@@ -1,3 +1,5 @@ | |||
import * as Asyncify from "https://unpkg.com/asyncify-wasm?module"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry that this bothers you. asyncify-wasm
is a small wrapper (163 LOC) around the Asyncify API and I thought using it could open up the possibility of implementing it ourselves later.
Asyncify really is a transform for source code, not a POSIX thing that emscripten implements in JavaScript.
The real change lies in the build.sh script by adding the wasm-opt
code transformation step.
If the code-transformation step does not fit this repository I am fine with that.
However this dependency issue can be resolved and I could implement that as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AntonPieper oh, if it's a small wrapper over something that depends only on a browser can we just implement our own version? Actually I kinda wanna explore whatever it is using myself.
P.S. Thank you for your pull requests and suggestion nonetheless. ❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could implement our own version, the thing that I wouldn't implement is the wasm-opt --asyncify
(wasm-opt is part of binaryen toolchain) pre-process step, it transforms the code and then exposes 4 function exports (asyncify_(start|stop)_(unwind|rewind)
). The JavaScript side then can unwind the stack by using these wasm exports, do async operations and then rewind the stack.
Here is a talk that I watched to understand Asyncify: Pause and Resume WebAssembly with Asyncify, Alon Zakai (~ 3:42-8:00 to get a grasp, optimizations at 17:48)
Asyncify using
asyncify-wasm
This branch adds Asyncify using a simple helper by GoogleChromeLabs and uses it for
requestAnimationFrame
. Maybe this can be explored further and the dependency could be dropped and inlined.By using Asyncify,
WindowShouldClose
can be implemented as an async function that "blocks" until the next frame is to be rendered.Changes
asyncify-wasm
by GoogleChromeLabsonchange
from index.html select box due to ES6 modulesCloses #24