Skip to content

Commit 815f592

Browse files
committed
Revert "Include OffscreenCanvas proxy logic only when necessary"
This reverts commit c9f172f.
1 parent 47161a8 commit 815f592

12 files changed

+17
-54
lines changed

src/library_html5.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,17 +2416,11 @@ var LibraryHTML5 = {
24162416
},
24172417

24182418
#if USE_PTHREADS
2419-
emscripten_set_canvas_element_size_calling_thread__deps: [
2420-
'$JSEvents',
2421-
#if OFFSCREENCANVAS_SUPPORT
2422-
'emscripten_set_offscreencanvas_size_on_target_thread',
2423-
#endif
2424-
'$findCanvasEventTarget'],
2419+
emscripten_set_canvas_element_size_calling_thread__deps: ['$JSEvents', 'emscripten_set_offscreencanvas_size_on_target_thread', '$findCanvasEventTarget'],
24252420
emscripten_set_canvas_element_size_calling_thread: function(target, width, height) {
24262421
var canvas = findCanvasEventTarget(target);
24272422
if (!canvas) return {{{ cDefine('EMSCRIPTEN_RESULT_UNKNOWN_TARGET') }}};
24282423

2429-
#if OFFSCREENCANVAS_SUPPORT
24302424
if (canvas.canvasSharedPtr) {
24312425
// N.B. We hold the canvasSharedPtr info structure as the authoritative source for specifying the size of a canvas
24322426
// since the actual canvas size changes are asynchronous if the canvas is owned by an OffscreenCanvas on another thread.
@@ -2436,7 +2430,6 @@ var LibraryHTML5 = {
24362430
{{{ makeSetValue('canvas.canvasSharedPtr', 0, 'width', 'i32') }}};
24372431
{{{ makeSetValue('canvas.canvasSharedPtr', 4, 'height', 'i32') }}};
24382432
}
2439-
#endif
24402433

24412434
if (canvas.offscreenCanvas || !canvas.controlTransferredOffscreen) {
24422435
if (canvas.offscreenCanvas) canvas = canvas.offscreenCanvas;
@@ -2460,12 +2453,10 @@ var LibraryHTML5 = {
24602453
// but this can be quite disruptive.
24612454
canvas.GLctxObject.GLctx.viewport(0, 0, width, height);
24622455
}
2463-
#if OFFSCREENCANVAS_SUPPORT
24642456
} else if (canvas.canvasSharedPtr) {
24652457
var targetThread = {{{ makeGetValue('canvas.canvasSharedPtr', 8, 'i32') }}};
24662458
_emscripten_set_offscreencanvas_size_on_target_thread(targetThread, target, width, height);
24672459
return {{{ cDefine('EMSCRIPTEN_RESULT_DEFERRED') }}}; // This will have to be done asynchronously
2468-
#endif
24692460
} else {
24702461
#if GL_DEBUG
24712462
err('canvas.controlTransferredOffscreen but we do not own the canvas, and do not know who has (no canvas.canvasSharedPtr present, an internal bug?)!\n');
@@ -2478,7 +2469,6 @@ var LibraryHTML5 = {
24782469
return {{{ cDefine('EMSCRIPTEN_RESULT_SUCCESS') }}};
24792470
},
24802471

2481-
#if OFFSCREENCANVAS_SUPPORT
24822472
emscripten_set_offscreencanvas_size_on_target_thread_js__deps: ['$stringToNewUTF8', 'emscripten_dispatch_to_thread_', '$withStackSave'],
24832473
emscripten_set_offscreencanvas_size_on_target_thread_js: function(targetThread, targetCanvas, width, height) {
24842474
withStackSave(function() {
@@ -2503,7 +2493,6 @@ var LibraryHTML5 = {
25032493
targetCanvas = targetCanvas ? UTF8ToString(targetCanvas) : '';
25042494
_emscripten_set_offscreencanvas_size_on_target_thread_js(targetThread, targetCanvas, width, height);
25052495
},
2506-
#endif
25072496

25082497
emscripten_set_canvas_element_size_main_thread__proxy: 'sync',
25092498
emscripten_set_canvas_element_size_main_thread__sig: 'iiii',
@@ -2566,7 +2555,6 @@ var LibraryHTML5 = {
25662555
var canvas = findCanvasEventTarget(target);
25672556
if (!canvas) return {{{ cDefine('EMSCRIPTEN_RESULT_UNKNOWN_TARGET') }}};
25682557

2569-
#if OFFSCREENCANVAS_SUPPORT
25702558
if (canvas.canvasSharedPtr) {
25712559
// N.B. Reading the size of the Canvas takes priority from our shared state structure, which is not the actual size.
25722560
// However if is possible that there is a canvas size set event pending on an OffscreenCanvas owned by another thread,
@@ -2575,9 +2563,7 @@ var LibraryHTML5 = {
25752563
var h = {{{ makeGetValue('canvas.canvasSharedPtr', 4, 'i32') }}};
25762564
{{{ makeSetValue('width', 0, 'w', 'i32') }}};
25772565
{{{ makeSetValue('height', 0, 'h', 'i32') }}};
2578-
} else
2579-
#endif
2580-
if (canvas.offscreenCanvas) {
2566+
} else if (canvas.offscreenCanvas) {
25812567
{{{ makeSetValue('width', 0, 'canvas.offscreenCanvas.width', 'i32') }}};
25822568
{{{ makeSetValue('height', 0, 'canvas.offscreenCanvas.height', 'i32') }}};
25832569
} else if (!canvas.controlTransferredOffscreen) {

system/include/emscripten/threading.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <pthread.h>
1212
#include <stdarg.h>
1313

14-
#include <emscripten/html5.h> // for EMSCRIPTEN_RESULT
14+
#include <emscripten/html5.h>
1515
#include <emscripten/atomic.h>
1616

1717
#ifdef __cplusplus

system/lib/pthread/library_pthread.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,10 @@ static void _do_call(void* arg) {
183183
// C function pointer
184184
assert(EM_FUNC_SIG_NUM_FUNC_ARGUMENTS(q->functionEnum) <= EM_QUEUED_CALL_MAX_ARGS);
185185
switch (q->functionEnum) {
186-
#ifdef __EMSCRIPTEN_OFFSCREEN_CANVAS__
187186
case EM_PROXIED_RESIZE_OFFSCREENCANVAS:
188187
q->returnValue.i =
189188
emscripten_set_canvas_element_size(q->args[0].cp, q->args[1].i, q->args[2].i);
190189
break;
191-
#endif
192190
case EM_PROXIED_JS_FUNCTION:
193191
q->returnValue.d =
194192
emscripten_receive_on_main_thread_js((int)(size_t)q->functionPtr, q->args[0].i, &q->args[1].d);

tests/other/metadce/minimal_main_Oz_USE_PTHREADS_PROXY_TO_PTHREAD.exports

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ B
33
C
44
D
55
E
6-
n
6+
F
7+
G
8+
H
79
o
810
p
911
q

tests/other/metadce/minimal_main_Oz_USE_PTHREADS_PROXY_TO_PTHREAD.funcs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ $em_queued_call_free
3636
$em_queued_call_malloc
3737
$emscripten_async_run_in_main_thread
3838
$emscripten_current_thread_process_queued_calls
39+
$emscripten_dispatch_to_thread_
3940
$emscripten_futex_wait
4041
$emscripten_futex_wake
4142
$emscripten_main_thread_process_queued_calls

tests/other/metadce/minimal_main_Oz_USE_PTHREADS_PROXY_TO_PTHREAD.imports

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ a.j
1111
a.k
1212
a.l
1313
a.m
14+
a.n
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
32193
1+
41444

tests/other/metadce/minimal_main_Oz_USE_PTHREADS_PROXY_TO_PTHREAD.sent

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ j
1111
k
1212
l
1313
m
14+
n
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
17004
1+
17350

tests/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11031,7 +11031,7 @@ def test_deps_info(self):
1103111031
cmd.append('-sMAIN_MODULE=2')
1103211032
if function.startswith('emscripten_idb') or function.startswith('emscripten_wget_'):
1103311033
cmd.append('-sASYNCIFY')
11034-
if function.startswith('emscripten_webgl_') or 'offscreencanvas' in function:
11034+
if function.startswith('emscripten_webgl_'):
1103511035
cmd.append('-sOFFSCREENCANVAS_SUPPORT')
1103611036
if function.startswith('wgpu'):
1103711037
cmd.append('-sUSE_WEBGPU')

tools/deps_info.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
'emscripten_run_script_string': ['emscripten_builtin_malloc', 'emscripten_builtin_free'],
108108
'emscripten_set_batterychargingchange_callback_on_thread': ['malloc'],
109109
'emscripten_set_batterylevelchange_callback_on_thread': ['malloc'],
110+
'emscripten_set_beforeunload_callback_on_thread': ['malloc'],
110111
'emscripten_set_blur_callback_on_thread': ['malloc'],
111112
'emscripten_set_click_callback_on_thread': ['malloc'],
112113
'emscripten_set_dblclick_callback_on_thread': ['malloc'],
@@ -128,8 +129,10 @@
128129
'emscripten_set_mouseout_callback_on_thread': ['malloc'],
129130
'emscripten_set_mouseover_callback_on_thread': ['malloc'],
130131
'emscripten_set_mouseup_callback_on_thread': ['malloc'],
132+
'emscripten_set_offscreencanvas_size_on_target_thread_js': ['malloc'],
131133
'emscripten_set_orientationchange_callback_on_thread': ['malloc'],
132134
'emscripten_set_pointerlockchange_callback_on_thread': ['malloc'],
135+
'emscripten_set_pointerlockerror_callback_on_thread': ['malloc'],
133136
'emscripten_set_resize_callback_on_thread': ['malloc'],
134137
'emscripten_set_scroll_callback_on_thread': ['malloc'],
135138
'emscripten_set_touchcancel_callback_on_thread': ['malloc'],
@@ -167,7 +170,7 @@
167170
'localtime': ['malloc'],
168171
'localtime_r': ['malloc'],
169172
'mktime': ['malloc'],
170-
'pthread_create': ['emscripten_main_thread_process_queued_calls'],
173+
'pthread_create': ['malloc', 'emscripten_main_thread_process_queued_calls'],
171174
'recv': ['htons'],
172175
'recvmsg': ['htons'],
173176
'accept': ['htons'],
@@ -213,9 +216,7 @@ def get_deps_info():
213216
# When OFFSCREEN_FRAMEBUFFER is defined these functions are defined in native code,
214217
# otherwise they are defined in src/library_html5_webgl.js.
215218
_deps_info['emscripten_webgl_destroy_context'] = ['emscripten_webgl_make_context_current', 'emscripten_webgl_get_current_context']
216-
if settings.USE_PTHREADS and settings.OFFSCREENCANVAS_SUPPORT:
217-
_deps_info['emscripten_set_offscreencanvas_size_on_target_thread'] = ['emscripten_dispatch_to_thread_', 'malloc', 'free']
218-
_deps_info['emscripten_set_offscreencanvas_size_on_target_thread_js'] = ['malloc']
219219
if settings.USE_PTHREADS:
220220
_deps_info['emscripten_set_canvas_element_size_calling_thread'] = ['emscripten_dispatch_to_thread_']
221+
_deps_info['emscripten_set_offscreencanvas_size_on_target_thread'] = ['emscripten_dispatch_to_thread_', 'malloc', 'free']
221222
return _deps_info

tools/system_libs.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -682,32 +682,6 @@ def get_default_variation(cls, **kwargs):
682682
return super().get_default_variation(is_asan=settings.USE_ASAN, **kwargs)
683683

684684

685-
class OffscreenCanvasSupportLibrary(Library):
686-
def __init__(self, **kwargs):
687-
self.is_ofc = kwargs.pop('is_ofc', False)
688-
super().__init__(**kwargs)
689-
690-
def get_cflags(self):
691-
cflags = super().get_cflags()
692-
if self.is_ofc:
693-
cflags += ['-D__EMSCRIPTEN_OFFSCREEN_CANVAS__']
694-
return cflags
695-
696-
def get_base_name(self):
697-
name = super().get_base_name()
698-
if self.is_ofc:
699-
name += '-ofc'
700-
return name
701-
702-
@classmethod
703-
def vary_on(cls):
704-
return super().vary_on() + ['is_ofc']
705-
706-
@classmethod
707-
def get_default_variation(cls, **kwargs):
708-
return super().get_default_variation(is_ofc=settings.OFFSCREENCANVAS_SUPPORT, **kwargs)
709-
710-
711685
# Subclass of SjLjLibrary because emscripten_setjmp.c uses SjLj support
712686
class libcompiler_rt(MTLibrary, SjLjLibrary):
713687
name = 'libcompiler_rt'
@@ -739,7 +713,6 @@ class libc(MuslInternalLibrary,
739713
DebugLibrary,
740714
OptimizedAggressivelyForSizeLibrary,
741715
AsanInstrumentedLibrary,
742-
OffscreenCanvasSupportLibrary,
743716
MTLibrary):
744717
name = 'libc'
745718

0 commit comments

Comments
 (0)