-
Notifications
You must be signed in to change notification settings - Fork 133
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 Worker usage on PS4 browser #1401
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
peaBerberian
added a commit
that referenced
this pull request
Mar 8, 2024
After #1401 (fix about the fact that `typeof Worker === "object"` on the PlayStation 4 for some reason), I finally succeeded to run the `MULTI_THREAD` experimental feature on a PlayStation 4 by adding one supplementary fix. Turns out that the `performance.now` web API, that we use to measure time differences (Date.now() being clock-related, it's not always appropriate for that) was not available in a Worker environment on the PlayStation 4. I have no idea why, as it is available in main thread, a random guess would be that this is a remnant of mitigations against something like spectre/meltdown but all I could find is that [they reduced its precision](https://trac.webkit.org/changeset/226495/webkit), not removed it from worker. Anyway, we thankfully only relied on this API at two places, as we voluntarily reduced those places previously to allow a synchronization mechanism between main thread and worker. This means that we can now easily use `Date.now()` in its place when `performance.now()` is unavailable without much fear of the issue coming back again in the future (our linter already ensure the API isn't used elsewhere). The main issue would be that timing measures would now become time-dependant on the PlayStation 4 and thus may be affected by clock changes, or subtle unix timestamp quirks. This should very rarely be problematic though, and it will just happen when the experimental `MULTI_THREAD` feature is explicitely relied on on the PlayStation 4 for now.
We noticed that ps4 applications were not relying on the `MULTI_THREAD` despite being theoretically compatible with it. Turns out that `typeof Worker` does not return `"function"` as expected with such objects but `"object"` instead on that browser. Thus, the RxPlayer believes that it hasn't access to the Worker API, the necessary requirement for the `MULTI_THREAD` feature. I suppose that this may also be true for other old Webkit-based browsers, though it isn't for recent-ish webkitgtk-based browsers on my PC, so for now I only enforce it for the PlayStation 4.
peaBerberian
force-pushed
the
fix/has-worker
branch
from
March 8, 2024 18:57
e42e1af
to
7a449a0
Compare
Florent-Bouisset
approved these changes
Mar 11, 2024
Merged
peaBerberian
added a commit
that referenced
this pull request
Jun 13, 2024
After #1401 (fix about the fact that `typeof Worker === "object"` on the PlayStation 4 for some reason), I finally succeeded to run the `MULTI_THREAD` experimental feature on a PlayStation 4 by adding one supplementary fix. Turns out that the `performance.now` web API, that we use to measure time differences (Date.now() being clock-related, it's not always appropriate for that) was not available in a Worker environment on the PlayStation 4. I have no idea why, as it is available in main thread, a random guess would be that this is a remnant of mitigations against something like spectre/meltdown but all I could find is that [they reduced its precision](https://trac.webkit.org/changeset/226495/webkit), not removed it from worker. Anyway, we thankfully only relied on this API at two places, as we voluntarily reduced those places previously to allow a synchronization mechanism between main thread and worker. This means that we can now easily use `Date.now()` in its place when `performance.now()` is unavailable without much fear of the issue coming back again in the future (our linter already ensure the API isn't used elsewhere). The main issue would be that timing measures would now become time-dependant on the PlayStation 4 and thus may be affected by clock changes, or subtle unix timestamp quirks. This should very rarely be problematic though, and it will just happen when the experimental `MULTI_THREAD` feature is explicitely relied on on the PlayStation 4 for now.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We noticed that ps4 applications were not relying on the
MULTI_THREAD
despite being theoretically compatible with it.Turns out that
typeof Worker
does not return"function"
as expected with such objects but"object"
instead on that browser. Thus, the RxPlayer believes that it hasn't access to the Worker API, the necessary requirement for theMULTI_THREAD
feature.I suppose that this may also be true for other old Webkit-based browsers, though it isn't for recent-ish webkitgtk-based browsers on my PC, so for now I only enforce it for the PlayStation 4.