Fix exception when trying to reference this inside callback (problem introduced by #5217)#5221
Merged
dmarcos merged 1 commit intoaframevr:masterfrom Jan 19, 2023
Merged
Conversation
this inside callback.this inside callback (problem introduced by #5217)
Member
|
Thanks, good catch! Sorry this bug slipped in. |
Merged
This file contains hidden or 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
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.
Description:
I recently proposed PR#5217 & it was merged. Unfortunately it triggers an exception on entry to WebXR, and also doesn't do what it was supposed to do.
This fixes that
Thanks to @mikemainguy for spotting this. He made a comment in #5217 yesterday, although I now can't find that comment, so maybe he since deleted it?
Changes proposed:
Originally submitted code was fatally flawed as it assumed that
thiswas bound to the element within a callback.I've corrected the code by using the
selfvariable instead.This is a complete screw-up by me. Sorry. Full disclosure on how this happened, so we (most of all me) can learn from this.
a-scenebecause the existing UTs in this area were limited, meaning it would have been a lot of work to extend them to cover this case. And since it was "only one line", I told myself the risk was low. If I had done a proper UT, I would have found the problem.Since master is broken right now (though the impact is just a console error, no other functional issues other than 5217 not actually working), I propose merging this fix now. I have tested this live on a Quest 2, including stepping through the code in the Chrome tools debugger.
Separately I will do a PR to extend coverage of the UTs for entering VR in WebXR mode (they currently focus on the legacy WebVR case).