Currently working on an application where we are looking to implement Picture in Picture (PiP). However, the camera feed in the UI that we want to continue is implemented from BaseArFragment from Sceneform.
The issue that we are facing is this. When entering PiP mode, the Android lifecycle goes through onPause(). Usually, this is not a problem for video applications because Android recommends to move the video pausing to onStop/onStart in the lifecycle. However, since our ArFragment is using BaseArFragment via Sceneform, the stopping of the sceneView is in the super.onPause where we cannot reach it. So the super.onPause is calling BaseArFragment.onPause which looks like the following:
@Override
public void onPause() {
super.onPause();
stop();
}
private void stop() {
if (!isStarted) {
return;
}
isStarted = false;
planeDiscoveryController.hide();
arSceneView.pause();
}
So when we call the onPause super method, it is pausing the arSceneView.
Our current hack is to check if PiP mode is active and if it is, calling onResume just after calling onPause. Feels very odd to do and may have unforseen consequences. Has anybody else been able to get an active Ar fragment working in PiP mode? If so, how?
Somewhat related, with the above hack when we return from PiP mode we are getting a DeadlineExceededException and a crash which we are unsure how to fix.