-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Open
Description
If I use PROXY_TO_PTHREAD and OFFSCREENCANVAS_SUPPORT I have to ifdef this part in updateCanvasDimensions() in https://github.com/emscripten-core/emscripten/blob/main/src/library_browser.js and set the size in the .html file instead (not sure, if this is a good solution, but it works):
updateCanvasDimensions : function(canvas, wNative, hNative) {
if (wNative && hNative) {
canvas.widthNative = wNative;
canvas.heightNative = hNative;
} else {
wNative = canvas.widthNative;
hNative = canvas.heightNative;
}
var w = wNative;
var h = hNative;
if (Module['forcedAspectRatio'] && Module['forcedAspectRatio'] > 0) {
if (w/h < Module['forcedAspectRatio']) {
w = Math.round(h * Module['forcedAspectRatio']);
} else {
h = Math.round(w / Module['forcedAspectRatio']);
}
}
if (((document['fullscreenElement'] || document['mozFullScreenElement'] ||
document['msFullscreenElement'] || document['webkitFullscreenElement'] ||
document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
var factor = Math.min(screen.width / w, screen.height / h);
w = Math.round(w * factor);
h = Math.round(h * factor);
}
if (Browser.resizeCanvas) {
if (canvas.width != w) canvas.width = w;
if (canvas.height != h) canvas.height = h;
if (typeof canvas.style != 'undefined') {
canvas.style.removeProperty( "width");
canvas.style.removeProperty("height");
}
} else {
#if !PROXY_TO_PTHREAD
if (canvas.width != wNative) canvas.width = wNative;
if (canvas.height != hNative) canvas.height = hNative;
#endif
if (typeof canvas.style != 'undefined') {
if (w != wNative || h != hNative) {
canvas.style.setProperty( "width", w + "px", "important");
canvas.style.setProperty("height", h + "px", "important");
} else {
canvas.style.removeProperty( "width");
canvas.style.removeProperty("height");
}
}
}
},
},
Otherwise I get this error message:
Uncaught DOMException: Failed to set the 'width' property on 'HTMLCanvasElement': Cannot resize canvas after call to transferControlToOffscreen().
at Object.updateCanvasDimensions (http://localhost:6931/EmscriptenExample.js:1:218824)
at Object.setCanvasSize (http://localhost:6931/EmscriptenExample.js:1:217256)
at _emscripten_set_canvas_size (http://localhost:6931/EmscriptenExample.js:1:223031)
at _emscripten_receive_on_main_thread_js (http://localhost:6931/EmscriptenExample.js:1:220745)
at _do_call (http://localhost:6931/EmscriptenExample.wasm:wasm-function[15107]:0x8a3324)
at emscripten_current_thread_process_queued_calls (http://localhost:6931/EmscriptenExample.wasm:wasm-function[15105]:0x8a2b6b)
at emscripten_main_thread_process_queued_calls (http://localhost:6931/EmscriptenExample.wasm:wasm-function[15117]:0x8a36c6)
at http://localhost:6931/EmscriptenExample.js:1:29890
at Worker.worker.onmessage (http://localhost:6931/EmscriptenExample.js:1:39637)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels