Search Unity

  1. Unity 2019.4 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  3. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

AR Foundation (Android) black screen on first launch bug (IL2CPP)

Discussion in 'Handheld AR' started by JasonJohn1977, May 2, 2019.

  1. JasonJohn1977

    JasonJohn1977

    Joined:
    Aug 12, 2013
    Posts:
    19
    Hello, I'm having issues after swapping from Mono backend to IL2CPP backend I'm finding the app prompts camera permissions but after allowing the screen stays black, if the app is closed and re-opened it then works fine, how can I remedy this so the camera works first time? (Problem doesn't occur with Mono backend)

    Thanks.
     
    Valeriya1129, grubertm and Blarp like this.
  2. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    556
    This used to be a problem on IL2CPP due to code stripping, but that was fixed a while ago. What version of the ARCore package do you have?
     
    Blarp likes this.
  3. JasonJohn1977

    JasonJohn1977

    Joined:
    Aug 12, 2013
    Posts:
    19
    I'm using version 1.0.0-preview.24 of ARCore XR Plugin and 1.0.0-preview.22 of AR foundation, it says they're both up to date in the package manager, unity version 2018.3.7f1.
     
  4. JasonJohn1977

    JasonJohn1977

    Joined:
    Aug 12, 2013
    Posts:
    19
    I've also tried updating Unity to 2019.1.0f2 and updating the packages to AR Foundation 1.10 (preview.6) and ARCore to 1.00-preview.24 but I'm still having the bug.
     
    grubertm likes this.
  5. BuoDev

    BuoDev

    Joined:
    Nov 28, 2018
    Posts:
    45
    I have this issue as well. First launch fails after requesting camera permission.
     
  6. BuoDev

    BuoDev

    Joined:
    Nov 28, 2018
    Posts:
    45
    @tdmowrer I sent you a private message with a full logcat of this.
     
  7. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    556
    Do you have a link.xml in your Assets folder? If not, ARFoundation should prompt you to create one. If you do, make sure you don't have any others elsewhere in your project as they may override this setting.
     
  8. grubertm

    grubertm

    Joined:
    Jan 9, 2018
    Posts:
    8
    Seeing the same bug here- works fine in Mono, but when using IL2CPP first-time startup shows black screen.
    There is only one link.xml file (auto-generated by AR Foundation) in my project.

    Google Pixel 3 (behavior is the same on multiple devices)
    Unity 2019.1.1f1
    AR Foundation 1.1.0 p6
    AR Core XR plugin 1.0.0 p24
    ARKit XR plugin 1.0.0 p27
     
  9. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    556
    This appears to be a code stripping issue. The ARCorePermissionsManager implements a Java interface, so the callbacks it uses aren't explicitly referenced by any other C# code. When managed code stripped is enabled or IL2CPP backend is used, this causes those methods to get stripped by Unity.

    We can prevent this in a future release of ARFoundation, but you can workaround it now by modifying your link.xml to

    Code (csharp):
    1. <assembly fullname="Unity.XR.ARCore" preserve="all" ignoreIfMissing="1"/>
    (note preserve="all" instead of "none")

    This may cause your apk to be a bit bigger but should fix the issue.
     
    grubertm and BuoDev like this.
  10. grubertm

    grubertm

    Joined:
    Jan 9, 2018
    Posts:
    8
    Thank you, that resolved the issue!
     
    rpifer94 likes this.
  11. KelsoSharp

    KelsoSharp

    Joined:
    Feb 24, 2018
    Posts:
    3
    Has this been fixed in newer versions of AR Foundation?
     
  12. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    556
    It will be fixed in the next release (going through QA right now).
     
  13. KelsoSharp

    KelsoSharp

    Joined:
    Feb 24, 2018
    Posts:
    3
    I have no link.xml do you have a full example of what it should contain? Including any other tags in the hierarchy.
     
  14. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    556
    Cross22 likes this.
  15. waldgeist

    waldgeist

    Joined:
    May 6, 2017
    Posts:
    96
    Having the same problem. Trying setting "none" to "all" now.
     
  16. santosh13

    santosh13

    Joined:
    Jun 12, 2019
    Posts:
    7
    Hi ,
    Created this AR application using AR Foundation in unity for both : ios and android.
    When built for ios everything was perfectly fine . also when built the same project for android with "Mono" back-end ( development build ) , everything was good , but when I built same thing using "IL2CPP" back-end , it gives following issues:'
    1. Black Screen problem
    2. Not detecting floor properly and object gets stuck to the camera ( I have attached a screenshots for this issue )

    Please help me to resolve this issue.
    thanks in Advance !
     

    Attached Files:

    sameel likes this.
  17. Alond

    Alond

    Joined:
    Dec 9, 2013
    Posts:
    7
    Hi
    I have the same IL2CPP black screen problem / not requesting camera permission problem but with Vuforia...
    Any workaround for that too?
    Thanks
     
  18. sameel

    sameel

    Joined:
    Dec 4, 2015
    Posts:
    15
    Having the same issue on Android too. In my case the issue is only the 2nd one, Not detecting the floor and object stuck to camera.
     
  19. aStrangeLoop

    aStrangeLoop

    Joined:
    Feb 17, 2018
    Posts:
    8
  20. Alex_Bo

    Alex_Bo

    Joined:
    Sep 18, 2014
    Posts:
    9
    On Unity 2019.3b11 with this solution I get a compile error:

    Failed running /Applications/Unity/Hub/Editor/2019.3.0b11/Unity.app/Contents/il2cpp/build/UnityLinker.exe -out="/Users/AlexBo/Development/UnityProjects/URP/Temp/StagingArea/assets/bin/Data/Managed/tempStrip" -x="/Users/AlexBo/Development/UnityProjects/URP/Temp/StagingArea/assets/bin/Data/Managed/../platform_native_link.xml" -x="/var/folders/nc/9blh334s75z5zxm02rn6dyg40000gn/T/tmpd1f4a6.tmp" -x="/Users/AlexBo/Development/UnityProjects/URP/Temp/StagingArea/assets/bin/Data/Managed/TypesInScenes.xml" -x="/Users/AlexBo/Development/UnityProjects/URP/Assets/link.xml" -d="/Users/AlexBo/Development/UnityProjects/URP/Temp/StagingArea/assets/bin/Data/Managed" --include-unity-root-assembly="/Users/AlexBo/Development/UnityProjects/URP/Temp/StagingArea/assets/bin/Data/Managed/Assembly-CSharp.dll" --include-unity-root-assembly="/Users/AlexBo/Development/UnityProjects/URP/Temp/StagingArea/assets/bin/Data/Managed/Unity.RenderPipelines.Core.Runtime.dll" --include-unity-root-assembly="/Users/AlexBo/Development/UnityProjects/URP/Temp/StagingArea/assets/bin/Data/Managed/Unity.RenderPipelines.Universal.Runtime.dll" --include-unity-root-assembly="/Users/AlexBo/Development/UnityProjects/URP/Temp/StagingArea/assets/bin/Data/Managed/UnityEngine.UI.dll" --dotnetruntime=il2cpp --dotnetprofile=unityaot --use-editor-options --include-directory="/Users/AlexBo/Development/UnityProjects/URP/Temp/StagingArea/assets/bin/Data/Managed" --rule-set=Conservative --editor-data-file="/Users/AlexBo/Development/UnityProjects/URP/Temp/StagingArea/assets/bin/Data/Managed/EditorToUnityLinkerData.json" --platform=Android --enable-engine-module-stripping --engine-stripping-flag=EnableUnityConnect --engine-stripping-flag=EnablePerformanceReporting --engine-stripping-flag=EnableAnalytics --engine-modules-asset-file="/Applications/Unity/Hub/Editor/2019.3.0b11/PlaybackEngines/AndroidPlayer/Whitelists/../modules.asset"

    stdout:
    Fatal error in Unity CIL Linker
    System.Xml.XmlException: Unexpected end of file has occurred. The following elements are not closed: linker. Line 3, position 9.
    at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <1d98d70bb7d8453b80c25aa561fdecd1>:0
    at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String arg) [0x00029] in <1d98d70bb7d8453b80c25aa561fdecd1>:0
    at System.Xml.XmlTextReaderImpl.Throw (System.Int32 pos, System.String res, System.String arg) [0x0000c] in <1d98d70bb7d8453b80c25aa561fdecd1>:0
    at System.Xml.XmlTextReaderImpl.ThrowUnclosedElements () [0x000cc] in <1d98d70bb7d8453b80c25aa561fdecd1>:0
    at System.Xml.XmlTextReaderImpl.ParseEndElement () [0x001f7] in <1d98d70bb7d8453b80c25aa561fdecd1>:0
    at System.Xml.XmlTextReaderImpl.ParseElementContent () [0x00149] in <1d98d70bb7d8453b80c25aa561fdecd1>:0
    at System.Xml.XmlTextReaderImpl.Read () [0x00085] in <1d98d70bb7d8453b80c25aa561fdecd1>:0
    at System.Xml.XPath.XPathDocument.LoadFromReader (System.Xml.XmlReader reader, System.Xml.XmlSpace space) [0x00228] in <1d98d70bb7d8453b80c25aa561fdecd1>:0
    at System.Xml.XPath.XPathDocument..ctor (System.String uri, System.Xml.XmlSpace space) [0x00013] in <1d98d70bb7d8453b80c25aa561fdecd1>:0
    at System.Xml.XPath.XPathDocument..ctor (System.String uri) [0x00000] in <1d98d70bb7d8453b80c25aa561fdecd1>:0
    at Unity.Linker.Steps.Resolution.UnityResolveFromXmlStep..ctor (System.String file) [0x00000] in <98b21eac6f13437abe8e0f36445fe9d3>:0
    at Unity.Linker.UnityDriver.ParseArguments (Mono.Linker.Pipeline p, Unity.Linker.UnityLinkContext context, System.Collections.ArrayList custom_steps, Mono.Linker.I18nAssemblies& assemblies) [0x001d1] in <98b21eac6f13437abe8e0f36445fe9d3>:0
    at Unity.Linker.UnityDriver.Run () [0x0001b] in <98b21eac6f13437abe8e0f36445fe9d3>:0
    at Unity.Linker.UnityDriver.RunDriverWithoutErrorHandling () [0x00007] in <98b21eac6f13437abe8e0f36445fe9d3>:0
    at Unity.Linker.UnityDriver.RunDriver () [0x00002] in <98b21eac6f13437abe8e0f36445fe9d3>:0
    stderr:

    UnityEngine.Debug:LogError(Object)
    UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:126)
    UnityEditorInternal.Runner:RunManagedProgram(String, String, String, CompilerOutputParserBase, Action`1) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:71)
    UnityEditorInternal.AssemblyStripper:RunAssemblyLinker(IEnumerable`1, String&, String&, String, String) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:166)
    UnityEditorInternal.AssemblyStripper:StripAssembliesTo(String, String&, String&, IEnumerable`1, UnityLinkerRunInformation) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:159)
    UnityEditorInternal.AssemblyStripper:RunAssemblyStripper(UnityLinkerRunInformation) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:301)
    UnityEditorInternal.AssemblyStripper:StripAssemblies(String, BaseUnityLinkerPlatformProvider, IIl2CppPlatformProvider, RuntimeClassRegistry, ManagedStrippingLevel) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/AssemblyStripper.cs:178)
    UnityEditorInternal.IL2CPPBuilder:Run() (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:327)
    UnityEditorInternal.IL2CPPUtils:RunIl2Cpp(String, String, IIl2CppPlatformProvider, Action`1, RuntimeClassRegistry) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:65)
    UnityEditor.EditorApplication:Internal_CallGlobalEventHandler() (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorApplication.cs:442)
     
  21. Zvky

    Zvky

    Joined:
    Sep 22, 2017
    Posts:
    2
    Make sure you close the linker tag
     
  22. jerinjc95

    jerinjc95

    Joined:
    May 13, 2019
    Posts:
    3
    I still have this issue, is it something new with the arfoundation?
     
  23. mariosubspace

    mariosubspace

    Joined:
    Nov 30, 2016
    Posts:
    1
    I was struggling to figure out the issue yesterday. The "ARCore XR Plugin" from the Package Manager has to also be installed along with the "AR Foundation" package. I had assumed that dependency would be installed automatically like the "AR Subsystems" package is (it makes sense why it isn't though). Project was building successfully with no errors in logcat it would just produce a black screen. It seems very obvious reading over the thread again but for some reason was not obvious to me before. Just thought I would make a note of it here if anyone has the same misunderstanding.
     
  24. cbannerjee

    cbannerjee

    Joined:
    Mar 17, 2020
    Posts:
    1
    I have this problem when the scripting backend is Mono as well as IL2CPP.

    I am have this issue on UNity 2019.2.17f1.
    I did not have a link.xml in the assets folder, manually created as suggested in link above:

    <linker>
    <assembly fullname="Unity.XR.ARFoundation" preserve="all" ignoreIfMissing="1"/>
    <assembly fullname="Unity.XR.ARExtensions" preserve="all" ignoreIfMissing="1"/>
    <assembly fullname="Unity.XR.ARCore" ignoreIfMissing="1" preserve="all"/>
    <assembly fullname="Unity.XR.ARKit" ignoreIfMissing="1" preserve="all"/>
    <assembly fullname="Unity.XR.ARKit.FaceTracking" ignoreIfMissing="1" preserve="all"/>
    </linker>


    Still getting a blank black screen.
    Any help is greatly appreciated!
     
    Last edited: Mar 17, 2020
  25. dantesryu

    dantesryu

    Joined:
    Oct 3, 2018
    Posts:
    1
    Hi, I'm getting the same problem here as well.
    Unity Version 2019.3.6
    ARFoundation 3.0.1
    ARCore XR Plugin 3.0.1
    ARKit XR Plugin 3.0.1
     
  26. nicolasfischoeder

    nicolasfischoeder

    Joined:
    Nov 7, 2018
    Posts:
    6
    Hey, I am also having the same problem. Using:
    Android 7
    Unity Version 2019.3.3f
    ARFoundation 2.1.4
    ARCore XR Plugin 2.1.2

    Basically I set up a scene with with a session and session origin GameObject and it doesn't work, the screen remains black.

    Edit:

    I Updated my phone to Android 8.0 and it is working now. Appearantly something is up with ARFoundation and Android 7.0.
     
    Last edited: Mar 27, 2020
  27. jinC_H

    jinC_H

    Joined:
    Aug 29, 2017
    Posts:
    7
    same black screen problem
    Unity Version 2019.3.7
    ARFoundation3.0.1
    ARCoreXR3.0
    With UniversalRenderpipline -ForwardRender-ARUniversalRenderPipelinesAsser
    build for android 8.0 Black Screen
     
  28. hfts

    hfts

    Joined:
    Apr 4, 2018
    Posts:
    1
    Same issue
    black screen problem
    Unity Version 2019.3.7
    Android 7.1
     
  29. imaginethepoet

    imaginethepoet

    Joined:
    Aug 23, 2016
    Posts:
    40
    Just tried this on a pixel 3a xl I got for development and same issue black screen. Seem pretty common, I’m not too familiar with android build right now so a bit lost.

    On iOS side I would expect this to be a camera permission issues.
     
  30. cchilin32

    cchilin32

    Joined:
    Feb 21, 2020
    Posts:
    1
    Hi, i have the same issue. I tried doing and finding what you were telling the people above me to do, but i just couldn't figure it out. Can you send us a video how to fix this issue or inform me of a video that fixes this issue?
     
  31. nudson

    nudson

    Joined:
    Oct 17, 2017
    Posts:
    1
    I was having a similar problem: getting black screen instead of camera feed, no prompt to use camera, camera access not granted, manually enabling camera access didn't help, the AR gods cursing me for no reason... Turns out my problem was different than the ones mentioned in this thread, so in case this will help anyone else, here's what I figured out:

    My scene has two cameras: a regular camera, for menus and all non-AR stuff parts of the app, and an AR camera, used only for the AR parts of the app. There's a script that switches between them as necessary. If I start the app with the AR camera enabled and the regular camera disabled, that script turns the AR camera off and uses the regular camera on Awake. This works fine in the editor, but gives me the Black Screen of Mystery on the phone. But if I turn the AR camera off and the regular camera on in the editor before building, it solves the problem on the phone.

    So I assume there's something going on where Android sees the app trying to access the camera, but then the app stops trying to use the camera when it switches to the non-AR camera at startup, so Android never prompts the user to allow access and some setting gets screwed and never fixed. I don't know, but this is what fixed it for me.
     
  32. mavc18

    mavc18

    Joined:
    Dec 26, 2018
    Posts:
    3
    i got the same problem in iOS, my ar foundation camera comes black when change between scenes... i pay plus plan give me a solution please!.
     
    Sprarage likes this.
  33. art1997

    art1997

    Joined:
    Apr 7, 2017
    Posts:
    26
    Hi all. wanted to try ARFoundation 4.1 for Depth api of arcore. but having black screen. any idea?

    Debug Message - "No active UnityEngine.XR.ARSubsystems.XRSessionSubsystem is available. Please ensure that a valid loader configuration exists in the XR project settings."
     
  34. todds_unity

    todds_unity

    Unity Technologies

    Joined:
    Aug 1, 2018
    Posts:
    147
    Be sure to configure the provider plugin for your target system.

    https://docs.unity3d.com/Packages/c...n@4.1/manual/index.html#provider-plugin-setup

    https://docs.unity3d.com/Packages/c.../migration-guide-3.html#xr-plug-in-management
     
unityunity