Unity-Technologies / arfoundation-samples

Example content for Unity projects based on AR Foundation
Other
3.07k stars 1.15k forks source link

[Bug][AR Foundation 4.1.7][Unity 2020.3.12f1] Black screen on iOS but works fine on Android #841

Closed dzak83 closed 3 years ago

dzak83 commented 3 years ago

Unity bug report case number (Case 1345857) Black screen from AR Foundation ARKit when targetTexture is used

Describe the bug We hit that regression after updating Unity from 2018 to 2019 and with AR Foundation version update. It seems like AR Camera is broken when Camera.targetTexture is set to RenderTexture. Calling this breaks video and RenderTexture will not receive video.

The same code worked fine on previous versions AND works fine on Android.

To Reproduce Steps to reproduce the behavior: (In the Unity bug attachment there is a sample project with everything but here are steps too)

  1. Setup: AR Foundation 4.1.7, Unity 2020.3.12f1
  2. New 3D project. Install AR Foundation with ARKit and ARCore. Mark check boxes in the XR settings. Set scripting define: UNITY_XR_ARKIT_LOADER_ENABLED.
  3. Add AR Sessions and AR Session Origin to the project
  4. Add script that will override targetTexture
  5. Add render texture and material to the project

image

image

image

From Awake, call logic that will set targetTexture. For debug, I am then displaying it in the OnGUI: image

Expected behavior AR Camera video should be saved into RenderTexture. OnGUI should show RenderTexture video. This works on Android and previous version of AR Foundation.

Actual behavior The moment we set Camera.targetTexture, video is broken on iOS. OnGUI is rendering black screen.

Workaround There is a way to fix if we use coroutine and wait few seconds before we set Camera.targetTexture = RenderTexture;. It would mean AR Camera is doing something with targetTexture or assigning it from Awake to camera is breaking AR Camera state.

Smartphone (please complete the following information):

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stevenbajer commented 3 years ago

I have the same problem in AR Foundation 4.17 version. According to the offical arfound samples, there is AR Subsystems packages in current project. But now I can not find AR Subsystems package in Unity Registery.

ankur-unity commented 3 years ago

I have the same problem in AR Foundation 4.17 version. According to the offical arfound samples, there is AR Subsystems packages in current project. But now I can not find AR Subsystems package in Unity Registery.

@stevenbajer - Please file a bug via https://unity3d.com/unity/qa/bug-reporting

You can also follow the progress on the bug filed by @dzak83 on our issue tracker.