IIRC the spec says canvas textures are destroyed when the current JavaScript event exits
This seems problematic for wasm projects. wasm appears to be getting JSPI support as a way to let wasm call asynchronous functions as though they were synchronous. Given that, any API call in a wasm might bottom out in a JSPI call. This means code like this
texture = context.getCurrentTexture();
callSomeFunction(); // happens to use JSPI directly or indirectly
...use texture here... // error: Texture is expired
Do we need to look into some way to manually commit the canvas texture? For example
device = await adapert.requestDevice({
features: ["canvas-manual-commit"],
});
context.configure({
device,
commit: "manual",
...
});
// -- at render time --
texture = context.getCurrentTexture();
callSomeFunction(); // happens to use JSPI directly or indirectly
... use texture here ...
context.commit(); // manually signal the texture should be swapped"
Or something? Is this an issue that needs solving? You could maybe argue that wasm should be using "bitmaprender" but if that's the solution, should that be the default in emscripten so that devs don't run into this gotcha issue?
I know discussion of manual commit/swap was discussed before. I'm wondering if this JSPI issue warrants a revisit.
IIRC the spec says canvas textures are destroyed when the current JavaScript event exits
This seems problematic for wasm projects. wasm appears to be getting JSPI support as a way to let wasm call asynchronous functions as though they were synchronous. Given that, any API call in a wasm might bottom out in a JSPI call. This means code like this
Do we need to look into some way to manually commit the canvas texture? For example
Or something? Is this an issue that needs solving? You could maybe argue that wasm should be using "bitmaprender" but if that's the solution, should that be the default in emscripten so that devs don't run into this gotcha issue?
I know discussion of manual commit/swap was discussed before. I'm wondering if this JSPI issue warrants a revisit.