Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix time source for wasm #2803

Merged
merged 1 commit into from Apr 16, 2024
Merged

fix time source for wasm #2803

merged 1 commit into from Apr 16, 2024

Conversation

DenizUgur
Copy link
Contributor

@DenizUgur DenizUgur commented Apr 14, 2024

In wasm build, usage of gettimeofday() is painfully slow when gpac runs on a worker. Emscripten offers a substitute for it. I had to make this change because when I profiled my application, almost all of the time wasm made a call to javascript to get the time and it stalled the entire stack because of it.

I haven't fully tested it but as emscripten documentation pointed out, this might use performance.now(). Which means between different workers (threads) this value will have a different origin (mdn reference). Depending on how these clocks are used internally the implementation might need to change. For reference, here is how this function is defined in emscripten:

https://github.com/emscripten-core/emscripten/blob/main/system/lib/standalone/standalone.c#L179-L185

fixes #2775
related urho3d/urho3d#916

@jeanlf jeanlf merged commit 87efbf2 into gpac:master Apr 16, 2024
@jeanlf
Copy link
Member

jeanlf commented Apr 16, 2024

According to the emscripten worker doc, using emscripten_get_now() should be time-aligned in pthreads, so I think we can merge. Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebAssembly: Add threading for download manager
2 participants