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

Event subtypes (XRSessionEvent) not working properly on Safari #130

Open
blairmacintyre opened this issue Dec 27, 2019 · 6 comments
Open

Comments

@blairmacintyre
Copy link
Contributor

On safari (mobile -- desktop doesn't "see" webxr so can't test), the inline-session example (at least) fails to "Exit VR" properly.

The issue seems to be with the way the XRSessionEvent is defined, created, and/or dispatched.

The event handler is received here:

      function onSessionEnded(event) {
        // Only reset the button when the immersive session ends.
        if (event.session.isImmersive) {
          xrButton.setSession(null);
        }
      }

On desktop Firefox (for example), things work properly: event is an XRSessionEvent and event.session.isImmersive exists.

On Safari, the event is showing up as an Event type, and the prototype does not have the session getter defined, so event.session fails.

I do not understand how to fix this, because the code appears correct ... could this be a bug in Safari's javascript? (I am trying to use this code as part of an update to the WebXR Viewer on iOS, but cannot see how to get this to work).

@blairmacintyre
Copy link
Contributor Author

Found this on SO, seems to confirm it's an issue with extending native classes on Safari https://stackoverflow.com/questions/58471434/problem-extending-native-es6-classes-in-safari

@jsantell
Copy link
Contributor

Found this on SO, seems to confirm it's an issue with extending native classes on Safari https://stackoverflow.com/questions/58471434/problem-extending-native-es6-classes-in-safari

Most likely it's this. I've made an EventTarget polyfill in the past specifically for not being able to extend EventTarget in Safari

@blairmacintyre
Copy link
Contributor Author

I implemented the suggested solution in the three places needed here, and it works fine. Should we just include that here? I'm happy to submit a PR.

@jsantell
Copy link
Contributor

jsantell commented Jan 1, 2020

I think there'll be some differences between the polyfilled EventTarget and the real one (some properties aren't modifiable on a synthesized event); I wonder if it should only be polyfilled on iOS (the linked polyfill doesn't handle injection). Either way, SGTM!

@blairmacintyre
Copy link
Contributor Author

blairmacintyre commented Jan 1, 2020 via email

@blairmacintyre
Copy link
Contributor Author

Here's the code to implement this fix. #133

blairmacintyre added a commit to mozilla-mobile/webxr-polyfill-for-ios-viewer that referenced this issue Jan 3, 2020
This is the code that fixes issue immersive-web#130
blairmacintyre added a commit to mozilla-mobile/webxr-polyfill-for-ios-viewer that referenced this issue Jan 3, 2020
This is the code that fixes issue immersive-web#130
jsantell pushed a commit that referenced this issue Jan 6, 2020
This is the code that fixes issue #130
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

No branches or pull requests

2 participants