You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pthread-main.js
+20-8Lines changed: 20 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,12 @@ var DYNAMIC_BASE = 0;
23
23
24
24
varENVIRONMENT_IS_PTHREAD=true;
25
25
26
+
// performance.now() is specced to return a wallclock time in msecs since that Web Worker/main thread launched. However for pthreads this can cause
27
+
// subtle problems in emscripten_get_now() as this essentially would measure time from pthread_create(), meaning that the clocks between each threads
28
+
// would be wildly out of sync. Therefore sync all pthreads to the clock on the main browser thread, so that different threads see a somewhat
29
+
// coherent clock across each of them (+/- 0.1msecs in testing)
30
+
var__performance_now_clock_drift=0;
31
+
26
32
// Cannot use console.log or console.error in a web worker, since that would risk a browser deadlock! https://bugzilla.mozilla.org/show_bug.cgi?id=1049091
27
33
// Therefore implement custom logging facility for threads running in a worker, which queue the messages to main thread to print.
}elseif(e.data.cmd==='run'){// This worker was idle, and now should start executing its pthread entry point.
115
+
__performance_now_clock_drift=performance.now()-e.data.time;// Sync up to the clock of the main thread.
109
116
threadInfoStruct=e.data.threadInfoStruct;
110
117
__register_pthread_ptr(threadInfoStruct,/*isMainBrowserThread=*/0,/*isMainRuntimeThread=*/0);// Pass the thread address inside the asm.js scope to store it for fast access that avoids the need for a FFI out.
# Test that emscripten_get_now() reports coherent wallclock times across all pthreads, instead of each pthread independently reporting wallclock times since the launch of that pthread.
0 commit comments