Open Maikol2712 opened 5 years ago
Faced this same issue with Unity 2018.4.4f1 and ARCore version 1.9.0. In my case there is black screen in my device and in the instant preview window it displays the camera view of my phone. Pretty weird issue. It is as if my camera is running but i cannot see anything but a black screen in my device and the camera is directly sending the view to the Instant preview window but not to my device.
I have the same problem. On Samsung Galaxy S8, ARCore SDK 1.10.0 and Unity 2019.1.13.
When running our game on the device I randomly get black screen upon startup of an AR scene (it displays the white 3D box logo in the center). Typically I can work around it by simply going to a non-AR scene (like our main menu) and then entering the AR scene again. But for our end-users the camera should work every time they start an AR scene in our game.
I remember this being a problem back in the beta days of ARCore, but I haven't seen it for a long time - until now. It started appearing again like 1-2 weeks ago.
An update to the ARCore plugin was released 25th of July this year, so I'm wondering if it's related to that update.
Any help would be much appreciated. Thanks a lot in advance!
I also see a similar issue on my Samsung Galaxy S8 (ARCore SDK 1.11.0 and Unity 2019.1.0f2). Not sure if it's exactly the same as OP because I don't need to restart to fix it (just close & repoen the app) - sounds more like @uffeflarup 's issue.
I think it's that the camera can't be connected to, and ARCore gives up. In adb logcat I get a lot of messages like:
08-12 16:45:39.281 9938 9992 E native : status.cc:153 ArStatusErrorSpace::AR_ERROR_DEADLINE_EXCEEDED: Point cloud only available on latest frame; at third_party/arcore/ar/core/session.cc:1576
08-12 16:45:39.285 9938 9992 W Unity : Failed to acquire point cloud with status ErrorDeadlineExceeded
08-12 16:45:39.285 9938 9992 W Unity : GoogleARCoreInternal.FrameApi:TryAcquirePointCloudHandle(IntPtr&)
08-12 16:45:39.285 9938 9992 W Unity : GoogleARCoreInternal.PointCloudManager:OnUpdate()
08-12 16:45:39.285 9938 9992 W Unity : GoogleARCoreInternal.ARCoreAndroidLifecycleManager:_OnEarlyUpdate()
08-12 16:45:39.285 9938 9992 W Unity : System.Action:Invoke()
and
android_camera.cc:1289 Camera 0: State ERROR: Capture session closed.
08-12 16:45:33.577 9938 9938 W native : session.cc:821 Session::Resume returning generic::deadline_exceeded: Camera 0: State ERROR: Timed out waiting for OPEN => CAPTURING.
After reading your comment, I have worked around it by disabling & re-enabling the AR Session whenever I see a ErrorDeadlineExceeded error. To do this, I made FrameAPI throw an error whenever there was an ErrorDeadlineExceeded error:
Debug.LogWarningFormat("Failed to acquire point cloud with status {0}", status);
if (status == ApiArStatus.ErrorDeadlineExceeded)
{
throw new PointCloudDeadlineExceededException("Failed to acquire point cloud with status" + status);
}
Then caught the error in ARCoreAndroidLifecycleManager, and called another script which did the restart.
try
{
NativeSession.OnUpdate(m_CachedFrameHandle);
}
catch(PointCloudDeadlineExceededException e)
{
Debug.Log("Caught PointCloudException " + e);
GameObject.FindObjectOfType<restartAR>().restartARController();
}
I also did a restart inside the error check part of ARCoreAndroidLifecycleManager (not sure if this is needed):
if (SessionStatus.IsError() &&
previousSessionStatus.IsError() != SessionStatus.IsError())
{
// Disable internal session bits so we properly pause the session due to error.
_FireOnSessionSetEnabled(false);
m_DisabledSessionOnErrorState = true;
//Disable and re-enable the session to try to restart.
GameObject.FindObjectOfType<restartAR>().restartARController();
My restartARController looks like the below, but I'm using the obsolete Unity ARController, so your method of re-initializing ARCore will probably need to be different. I found that the CoRoutine was necessary (presumably because it allows a gap between the disable and re-enable).
public class restartAR : MonoBehaviour
{
public UnityARInterface.ARController arController;
public void restartARController()
{
Debug.Log("restartARController called.");
StartCoroutine(restartARRoutine());
}
private IEnumerator restartARRoutine()
{
Debug.Log("restartARController routine started.");
yield return new WaitForSeconds(0.1f);
Debug.Log("restartARController disabling arController...");
arController.enabled = false;
yield return new WaitForSeconds(0.1f);
Debug.Log("restartARController enabling arController...");
arController.enabled = true;
Debug.Log("restartARController routine finished.");
}
}
There are probably more places that should throw the same exception (I imagine it could happen on events other than aquiring the point cloud), and there are probably better ways of restarting the ARCore session, but I tried different ways for quite a while and this was the version that worked reliably for me.
A proper fix (rather than my dodgy workaround) would be very much appreciated!
@Crashthatch Thanks a lot for sharing this. I'll probably end up making something similar also.
But like you, I also think that a proper fix from the ARCore team would be the correct solution.
I faced the same issue but was able to resolve it. After installing Multiplayer HLAPI and XR Legacy Input Helpers. The Multithreaded rendering option pops up, you need to uncheck it. And need to make sure in XR settings after checking ARCore Supported there is no warnings. In my case the waring was to remove one entry from the graphics api, which I did And camera popped up.
SPECIFIC ISSUE ENCOUNTERED
Android application show black screen. Instant Preview shows white screen.
VERSIONS USED
adb shell pm dump com.google.ar.core | findstr /i "packages: versionName"
On macOS, use:adb shell pm dump com.google.ar.core | egrep -i versionName\|packages:
adb shell getprop ro.build.fingerprint
:STEPS TO REPRODUCE THE ISSUE
WORKAROUNDS (IF ANY)
Restart the android device.
ADDITIONAL COMMENTS
Initially, the application may render the camera fine, but once the problem shows up (random apparently), it does not get fixed until the device is restarted.
When importing the ARCore SDK package, this error shows in console: