Bug 1479424 - Fix VRManager NotifyVSync not called when compositor is paused on Android; r=kip,rbarker

MozReview-Commit-ID: JY8xyCSKIgv

--HG--
extra : rebase_source : 8ae0ba070bba5cc03137c4053a7730ad89090e96
This commit is contained in:
Imanol Fernandez 2018-07-30 18:14:05 +02:00
Родитель 0471de08a0
Коммит 25d362ba4f
2 изменённых файлов: 36 добавлений и 0 удалений

Просмотреть файл

@ -117,11 +117,45 @@ VRDisplayExternal::StartPresentation()
mBrowserState.layerState[0].type = VRLayerType::LayerType_Stereo_Immersive; mBrowserState.layerState[0].type = VRLayerType::LayerType_Stereo_Immersive;
PushState(); PushState();
#if defined(MOZ_WIDGET_ANDROID)
/**
* Android compositor is paused when presentation starts. That causes VRManager::NotifyVsync() not to be called.
* We post a VRTask to call VRManager::NotifyVsync() while the compositor is paused on Android.
* VRManager::NotifyVsync() should be called constinuosly while the compositor is paused because Gecko WebVR Architecture
* relies on that to act as a "watchdog" in order to avoid render loop stalls and recover from SubmitFrame call timeouts.
*/
PostVRTask();
#endif
// TODO - Implement telemetry: // TODO - Implement telemetry:
// mTelemetry.mLastDroppedFrameCount = stats.m_nNumReprojectedFrames; // mTelemetry.mLastDroppedFrameCount = stats.m_nNumReprojectedFrames;
} }
#if defined(MOZ_WIDGET_ANDROID)
void
VRDisplayExternal::PostVRTask() {
MessageLoop * vrLoop = VRListenerThreadHolder::Loop();
if (!vrLoop || !mBrowserState.presentationActive) {
return;
}
RefPtr<Runnable> task = NewRunnableMethod(
"VRDisplayExternal::RunVRTask",
this,
&VRDisplayExternal::RunVRTask);
VRListenerThreadHolder::Loop()->PostDelayedTask(task.forget(), 50);
}
void
VRDisplayExternal::RunVRTask() {
if (mBrowserState.presentationActive) {
VRManager *vm = VRManager::Get();
vm->NotifyVsync(TimeStamp::Now());
PostVRTask();
}
}
#endif // defined(MOZ_WIDGET_ANDROID)
void void
VRDisplayExternal::StopPresentation() VRDisplayExternal::StopPresentation()
{ {

Просмотреть файл

@ -60,6 +60,8 @@ private:
void PushState(bool aNotifyCond = false); void PushState(bool aNotifyCond = false);
#if defined(MOZ_WIDGET_ANDROID) #if defined(MOZ_WIDGET_ANDROID)
bool PullState(const std::function<bool()>& aWaitCondition = nullptr); bool PullState(const std::function<bool()>& aWaitCondition = nullptr);
void PostVRTask();
void RunVRTask();
#else #else
bool PullState(); bool PullState();
#endif #endif