Skip to content

Commit b4aba23

Browse files
committed
Merge branch 'main' into always-bulkmem
2 parents 747201c + b3edd4c commit b4aba23

File tree

5 files changed

+45
-14
lines changed

5 files changed

+45
-14
lines changed

src/library_html5_webgl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ var LibraryHtml5WebGL = {
171171
#endif
172172
return 0;
173173
}
174-
canvas = GL.offscreenCanvases[canvas.id];
174+
canvas = GL.offscreenCanvases[canvas.id].canvas;
175175
}
176176
}
177177
#else // !OFFSCREENCANVAS_SUPPORT

src/library_sockfs.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -728,24 +728,19 @@ addToLibrary({
728728
* Passing a NULL callback function to a emscripten_set_socket_*_callback call
729729
* will deregister the callback registered for that Event.
730730
*/
731-
$_setNetworkCallback__deps: ['$stackSave', '$stackRestore', '$stringToUTF8OnStack'],
731+
$_setNetworkCallback__deps: ['$withStackSave', '$callUserCallback', '$stringToUTF8OnStack'],
732732
$_setNetworkCallback: (event, userData, callback) => {
733733
function _callback(data) {
734-
try {
734+
callUserCallback(() => {
735735
if (event === 'error') {
736-
var sp = stackSave();
737-
var msg = stringToUTF8OnStack(data[2]);
738-
{{{ makeDynCall('viiii', 'callback') }}}(data[0], data[1], msg, userData);
739-
stackRestore(sp);
736+
withStackSave(() => {
737+
var msg = stringToUTF8OnStack(data[2]);
738+
{{{ makeDynCall('viiii', 'callback') }}}(data[0], data[1], msg, userData);
739+
});
740740
} else {
741741
{{{ makeDynCall('vii', 'callback') }}}(data, userData);
742742
}
743-
} catch (e) {
744-
if (!(e instanceof ExitStatus)) {
745-
if (e && typeof e == 'object' && e.stack) err('exception thrown: ' + [e, e.stack]);
746-
throw e;
747-
}
748-
}
743+
});
749744
};
750745

751746
// FIXME(sbc): This has no corresponding Pop so will currently keep the

src/shell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ if (ENVIRONMENT_IS_SHELL) {
319319
globalThis.clearTimeout ??= (id) => {};
320320

321321
// spidermonkey lacks setTimeout but we use it above in readAsync.
322-
globalThis.setTimeout ??= (f) => (typeof f == 'function') ? f() : abort();
322+
globalThis.setTimeout ??= (f) => f();
323323

324324
// v8 uses `arguments_` whereas spidermonkey uses `scriptArgs`
325325
arguments_ = globalThis.arguments || globalThis.scriptArgs;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2024 The Emscripten Authors. All rights reserved.
2+
// Emscripten is available under two separate licenses, the MIT license and the
3+
// University of Illinois/NCSA Open Source License. Both these licenses can be
4+
// found in the LICENSE file.
5+
6+
#include <GLES2/gl2.h>
7+
#include <GLES2/gl2ext.h>
8+
#include <assert.h>
9+
10+
#include <emscripten/emscripten.h>
11+
#include <emscripten/html5.h>
12+
13+
int main() {
14+
EmscriptenWebGLContextAttributes attrs;
15+
emscripten_webgl_init_context_attributes(&attrs);
16+
attrs.explicitSwapControl = true;
17+
#ifdef USE_OFFSCREEN_FRAMEBUFFER
18+
attrs.renderViaOffscreenBackBuffer = true;
19+
#endif
20+
// Test that creating a context succeeds
21+
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context("#canvas", &attrs);
22+
assert(context > 0); // Must have received a valid context.
23+
EMSCRIPTEN_RESULT res = emscripten_webgl_make_context_current(context);
24+
assert(res == EMSCRIPTEN_RESULT_SUCCESS);
25+
assert(emscripten_webgl_get_current_context() == context);
26+
return 0;
27+
}

test/test_browser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,6 +2612,15 @@ def test_html5_webgl_create_context(self, args):
26122612
def test_html5_webgl_create_context2(self):
26132613
self.btest_exit('webgl_create_context2.cpp')
26142614

2615+
@requires_graphics_hardware
2616+
# Verify bug https://github.com/emscripten-core/emscripten/issues/22943: creating a WebGL context with explicit swap control and offscreenCanvas
2617+
@parameterized({
2618+
'offscreencanvas': (['-sOFFSCREENCANVAS_SUPPORT'],),
2619+
'offscreenframebuffer': (['-sOFFSCREEN_FRAMEBUFFER', '-DUSE_OFFSCREEN_FRAMEBUFFER'],),
2620+
})
2621+
def test_html5_webgl_create_context_swapcontrol(self, args):
2622+
self.btest_exit('browser/webgl_create_context_swapcontrol.c', args=args)
2623+
26152624
@requires_graphics_hardware
26162625
# Verify bug https://github.com/emscripten-core/emscripten/issues/4556: creating a WebGL context to Module.canvas without an ID explicitly assigned to it.
26172626
# (this only makes sense in the old deprecated -sDISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 mode)

0 commit comments

Comments
 (0)