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

Correct ExternaVR shutdown #550

Merged
merged 1 commit into from
Sep 28, 2018
Merged

Correct ExternaVR shutdown #550

merged 1 commit into from
Sep 28, 2018

Conversation

MortimerGoro
Copy link
Contributor

Copy link
Contributor

@bluemarvin bluemarvin left a comment

Choose a reason for hiding this comment

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

I wish the WebVR external wasn't so fragile. It seems like small changes in gfxExternalVR will break this. I guess we just need to add some tests at some point. 🙂

// Otherwise the shmem data may be deallocated before Gecko processes it, leading to undefined behaviour
Wait wait(m.data.browserMutex, m.data.browserCond);
wait.Lock();
m.PullBrowserStateWhileLocked();
Copy link
Contributor

Choose a reason for hiding this comment

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

This got me thinking about how to deal with the PullBrowserStateWhileLocked() issue. I wonder if we could use a closure to fix this issue where the code would look something like:

void PullBrowserState(std::function<bool(const BrowserState&)>& aFunc, float aWait = 0.0f) {
  wait.lock();
  copy_data();
  while(!aFunc(m.browserState)) {
    if (!wait.DoWait(aWait)) {
     break;
    }
    copy_data()
  }
}

@bluemarvin
Copy link
Contributor

I applied the GV patch and pulled this and built and I don't think it is working. STR on the Go:

  1. Go to https://tonite.dance
  2. Enter immersive mode.
  3. Press the home button.
  4. Exit FxR
  5. Relaunch FxR

Expected: FxR launches with https://tonite.dance as the currently loaded page not in immersive mode. But the user is able to enter immersive mode.
Actual: Black screen and the Go is hung requiring a system reboot, or FxR crashes, or FxR fails to enter immersive mode.

Copy link
Contributor

@bluemarvin bluemarvin left a comment

Choose a reason for hiding this comment

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

From my testing the external struct is not getting removed from Gecko.

@bluemarvin
Copy link
Contributor

I'm seeing this in the log:
09-19 14:34:35.860 2437 3092 W VRB : FXR Shutdown wait timeout

@MortimerGoro
Copy link
Contributor Author

MortimerGoro commented Sep 21, 2018

I changed the approach to use the static struct we talked about in slack.

Even with that sometimes the next relaunch was a black screen. I found that sometimes there is a deadlock in onDestroy when the browser widget is released (on the display.SurfaceDestroyed() call, which stops the compositor using a sync() call). This only happens when the activity is destroyed while presenting immersive.

It seems that there is a race condition where the immersive mode is not paused before onDestroy arrived, probably because the frame loop is stopped before the event sent from onPause is processed. I made the exitImmersive() call sync in onPause to fix the issue.

This problem could happen with the previous killProcess too.

@bluemarvin
Copy link
Contributor

@MortimerGoro I assume this no longer requires the Gecko patch?

@MortimerGoro
Copy link
Contributor Author

@bluemarvin yes, the GV patch is no longer required. I just set the shutdown flag for correctness.

Copy link
Contributor

@bluemarvin bluemarvin left a comment

Choose a reason for hiding this comment

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

Just fix-up where ExternVR is creating the shared_ptr<> in Create. Otherwise, looks good.

@@ -179,6 +190,8 @@ struct ExternalVR::State {
}
};

ExternalVR::State * ExternalVR::State::sState = nullptr;

ExternalVRPtr
ExternalVR::Create() {
return std::make_shared<vrb::ConcreteClass<ExternalVR, ExternalVR::State> >();
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the state is no longer instanced with the class this should be:

return std::make_shared<ExternalVR>();

And #include "vrb/ConcreteClass.h" can be removed.

@bluemarvin
Copy link
Contributor

I'm seeing a dead lock when restarting:
STR:

  1. Go to https://tonite.dance
  2. Enter immersive mode
  3. Press home button on controller
  4. Press exit button
  5. Launch FxR again
  6. Goto 2)

Expected: Should be able to do this indefinitely
Actual: After going in and out several times, FxR will hang on launch and just show a black screen after step 5)

@MortimerGoro
Copy link
Contributor Author

I removed the shutdown flag, it was causing some intermittent EnterVR problem after a restart. I can't reproduce the deadlock when restarting (trying with the Go).

The only thing I saw is sometimes there is a whole app restart because of #586. It's not easy to reproduce, it seems easier following the STR steps with https://webvr.info/samples/03-vr-presentation.html

@bluemarvin
Copy link
Contributor

Can no longer reproduce hang issue.

@bluemarvin bluemarvin merged commit 2b8f04b into master Sep 28, 2018
@bluemarvin bluemarvin deleted the shutdown branch October 9, 2018 19:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants