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 Worker usage on PS4 browser #1401

Merged
merged 1 commit into from
Mar 11, 2024
Merged

Fix Worker usage on PS4 browser #1401

merged 1 commit into from
Mar 11, 2024

Conversation

peaBerberian
Copy link
Collaborator

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 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 peaBerberian merged commit 95274b9 into dev Mar 11, 2024
6 checks passed
@peaBerberian peaBerberian added this to the 4.1.0 milestone Mar 14, 2024
@peaBerberian peaBerberian mentioned this pull request Jun 13, 2024
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.
@peaBerberian peaBerberian deleted the fix/has-worker branch July 26, 2024 16:23
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.

2 participants