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: addEventListener in navigator.xr seems to throw in some cases #23805

Merged
merged 1 commit into from
Mar 31, 2022

Conversation

hybridherbst
Copy link
Contributor

@hybridherbst hybridherbst commented Mar 29, 2022

Description

We encountered a weird page crash in Mozilla's WebXR viewer and XR Browser (fork of the former).
Turns out that while those have "navigator.xr", they throw a funny exception when someone actually uses it:

// @TODO: Relax this add/remove/dispatch event limitations?
Shim: We don't expect user adds event before stating session

...

So this PR simply catches that exception. Can't hurt I think...

Relevant user agents:

Firefox iOS (does not currently have navigator.xr)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15

XRViewer (silent exception when accessing addEventListener)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile WebXRViewer/v2.0(280)

XR Browser (silent exception when accessing addEventListener)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 WebXRViewer/1.0 Safari/605.1.15

@mrdoob
Copy link
Owner

mrdoob commented Mar 29, 2022

Can we do user agent check instead? Makes the code more readable/maintainable.

@hybridherbst hybridherbst force-pushed the catch-exception-in-sessiongranted branch from c2a3d1b to 4746d6f Compare March 30, 2022 18:49
@hybridherbst hybridherbst force-pushed the catch-exception-in-sessiongranted branch from 4746d6f to 4b66b04 Compare March 30, 2022 19:04
@hybridherbst
Copy link
Contributor Author

@mrdoob I agree and did now change it to a UA check. Thanks for the feedback!

@mrdoob mrdoob added this to the r140 milestone Mar 31, 2022
@mrdoob mrdoob merged commit 0da9a14 into mrdoob:dev Mar 31, 2022
@mrdoob
Copy link
Owner

mrdoob commented Mar 31, 2022

Thanks!

@hybridherbst hybridherbst deleted the catch-exception-in-sessiongranted branch April 30, 2022 16:28
abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
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.

3 participants