Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

fix issues with {getFrameData,submitFrame} must be called within a VRDisplay.requestAnimationFrame callback. (fixes issue #65); fix JS errors Screen position out of view frustum in Chrome Canary (fixes issue #64) #132

Merged
merged 3 commits into from
Feb 16, 2018

Conversation

cvan
Copy link
Contributor

@cvan cvan commented Feb 13, 2018

Fix #64
Fix #65

seems to work well. feedback to approach, including possible edge cases I've missed, welcome.
tested with HTC VIVE on Windows 10 in both Chrome Canary and Firefox Nightly.

@cvan cvan added the bug label Feb 13, 2018
@cvan cvan added this to the Polished community release milestone Feb 13, 2018
@cvan cvan self-assigned this Feb 13, 2018
@cvan cvan requested review from delapuente and caseyyee February 13, 2018 12:45
Copy link
Contributor

@caseyyee caseyyee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cvan Tested with FF and Chrome Canary, looks to be working well. The only thing that broke is that we're starting out in the ground.

Looks like were not hitting the stageParameters bits:
https://github.com/mozilla/unity-webvr-export/blob/master/Assets/WebGLTemplates/WebVR/webvr.js#L123-L124

image

@cvan
Copy link
Contributor Author

cvan commented Feb 14, 2018

@cvan Tested with FF and Chrome Canary, looks to be working well. The only thing that broke is that we're starting out in the ground.

thanks for testing. any ideas how to fix? did you check + build on master to compare?

Build/index.html Outdated
@@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unity-WebVR-Export</title>
<meta name="description" content="Unity-WebVR-Export">
<title> | Unity-WebVR-Export</title>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this hasn't been updated on master when y'all have built the project

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too. I don't understand why.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have issue #116 filed. (I just upgraded to the .3 version of Unity; mayve that'll change things. I'll let you know.) thanks!

function onUnityLoaded() {

function onUnityLoaded () {
// Get and hide Unity's `<canvas>` instance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the comment. What you are hiding is the loader, not the <canvas>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this got moved in some merge/stash-patch applied. will remove.

console.log('vr exit present success!')
function onExitPresent () {
if (!vrDisplay && !vrDisplay.isPresenting) {
throw new Error('No VR display to exit VR mode');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use a console.warn() here and fail silently but it's your call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the VRManager, I've got in a local branch (initially started for this, and then for #104, and so on), I have turned these functions into methods, and this places nicely with it.

I'm cool with removing that for now. thanks for mentioning the inconsistency; it was bothering me too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw you replaced a different throw with a warning but what about this exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I missed this one. got distracted with the launch logistics today. will resivit this on Tuesday. (I’m PTO tomorrow, and Monday is a US holiday.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. I'll do.

// `vrDisplay.submitFrame(…)`. So for the first frame that this is called, we will
// abort early and request a new frame from the VR display instead.
if (vrDisplay.isPresenting && !submitNextFrame) {
submitNextFrame = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the conditional is true, then submitNextFrame is already false. What's the point of this assignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doy, that's what I get for working late. I should be checking only !submitNextFrame. thanks.

and that order does matter; I don't know if the comment above makes sense. anything I clarify?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like the flag, if true, ensures that we are inside a vrDisplay.requestAnimationFrame. Anyway, it was clear enough for me. Perhaps we can think of a better fix when addressing #104

window.requestAnimationFrame(onAnimate);
function onAnimate () {
if (!vrDisplay || !vrDisplay.isPresenting) {
windowRaf(onAnimate);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a kind of active polling, so you repeat the check on vrDisplay. I would prefer this to be event-driven but if that's not possible, can you clarify why you are rescheduling onAnimate in a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could actually remove these lines, good call. they were leftovers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they are leftovers, please, do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven’t step-debugged the rAF calls. but I think if I add a debugger call to the monkeypatched window.requestAnimationFrame function, I can see how often and when Unity’ s WebGL Engine makes the calls. I want to minimise the rAF calls as much as possible. in my testing today, I removed this block and didn’t notice any degradation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking. Let's move to #104

@@ -22,7 +22,7 @@
],
"screenshots": [
{
"src": "https://raw.githubusercontent.com/caseyyee/unity-webvr-export/master/img/preview.gif",
"src": "https://raw.githubusercontent.com/mozilla/unity-webvr-export/master/img/preview.gif",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@delapuente: how come these changes weren't changed when you did the builds manually yourself? do we have something wonky set up here?

I'd be curious to get on Vidyo together, the three of us, and compare our Unity flows. I'm sure there are some interesting workflows and edge cases we're handling differently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to do it. Send an invitation if you want.

@cvan
Copy link
Contributor Author

cvan commented Feb 14, 2018

I pulled, rebased, but I'm still getting these conflicts according to GitHub. hmm… I'll have to look in the morning (my morning).

@cvan
Copy link
Contributor Author

cvan commented Feb 14, 2018

@delapuente @caseyyee: ignoring the Build/ mess, I just want to make sure that these changes (really just to Assets/WebGLTemplates/WebVR/webvr.js and Build/webvr.js) run smoothly for you and with no discernible regressions.

thanks for reviewing and testing, you both 👍

@delapuente
Copy link
Contributor

delapuente commented Feb 14, 2018

No problem Chris, if you can not solve the issues, I will rebase it. I'm having problems with my VIVE right now and cannot wake the base stations up so I can not test it. Go to sleep. ZzzZzz

@delapuente
Copy link
Contributor

delapuente commented Feb 14, 2018

This is inevitable:

@cvan Tested with FF and Chrome Canary, looks to be working well. The only thing that broke is that we're starting out in the ground.

Now, when not presenting, we are not updating the camera matrices (which is mandatory because getFrameData must be called inside vrDisplay.requestAnimationFrame too). For me, it makes perfect sense since we are returning the control to Unity's camera system. If this is the desired behaviour, we must also reset the effect of setting worldToCameraMatrix by calling Camera#ResetWorldToCameraMatrix on all the cameras of the WebVR rigging. It can be done when handling the End message sent from JavaScript to Unity.

@delapuente
Copy link
Contributor

@cvan working as expected on my side. Solve the issues and grant me access to your repo if you need help with the rebasing. Nice work. These are all valuable steps towards #104

@caseyyee
Copy link
Contributor

@delapuente with the polyfill, it should still update (this should be the old version still?)

If we replaced it with the newer one, then yeah. It won't hit that code path.

@delapuente
Copy link
Contributor

@delapuente with the polyfill, it should still update (this should be the old version still?)

Even with the polyfill, the execution will never hit that code path (notice the test condition and the early return)

@delapuente
Copy link
Contributor

delapuente commented Feb 15, 2018

@cvan, I've discarded your changes on Build/ to ease the rebase. I'll regenerate them and push to master once this is merged. Please, address the changes and remember to not commit the changes on Build/. Thank you so much, let's fix two bugs for the price of one!

cvan and others added 3 commits February 15, 2018 18:11
…RDisplay.requestAnimationFrame callback.` (fixes issue #65); fix JS errors `Screen position out of view frustum` in Chrome Canary (fixes issue #64)
@delapuente delapuente merged commit 7faf2e8 into MozillaReality:master Feb 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants