PTCInc / vuforia-engine

Bug and feedback issue tracker for the Vuforia Engine SDK
https://developer.vuforia.com
19 stars 0 forks source link

Android Config Initialization Error, Failed to Initialize Vuforia Engine #101

Closed slabarque closed 2 months ago

slabarque commented 6 months ago

Summarize the bug: Android app runs succesfully when running for the first time. When closing the app and reopening it, I get "Vuforia Engine Initialization Error"

Observed problem I created a Unity project (2023.2.12f1) with Vuforia Engine 10.21.3, exporting and running it on Android. The first time the app is started, it requests the missing camera permissions as expected and the engine gets initialized. No matter, if I select "only once" or "when using the app", the next time I start the app, there is no request for camera permissions and the app crashes with a vuforia engine initialization error (see Device logs).

If I manually set the camera permissions to none in the android settings for the app, the next time I start the app, permissions get requested again and the engine initializes flawlessly. If I manually change back to other settings then none, app crashes again with the same error. So it only works once after I removed the camera permissions manually.

It seems, vuforia is not initializing correctly, when the app already has camera permissions.

This issue is also described on stackoverflow: https://stackoverflow.com/questions/77759311/vuforia-engine-failed-to-initialize-on-android-in-unity-app

The post there is not mine, but I have the exact same problem.

Expected result I expect the app to run succesfully, without this configuration error every time I start it.

Other observations See detailed description

Reproducible steps

Affected Vuforia Engine version: v10.21.3

Affected platform: Android

Affected device: Google Pixel 7

Screenshots / Video Recordings "Vuforia Engine Initialization Error"

Affected database Not applicable

Device or platform logs

2024/01/04 16:02:17.120 21431 21451 Error AR 2024-01-04 16:02:17: Initialization of platform integration failed
2024/01/04 16:02:17.121 21431 21451 Error AR 2024-01-04 16:02:17: Creating Vuforia Engine instance...FAILED
2024/01/04 16:02:17.124 21431 21451 Error Unity Failed to create Vuforia engine: Unknown Vuforia Engine initialization error
2024/01/04 16:02:17.124 21431 21451 Error Unity UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
2024/01/04 16:02:17.124 21431 21451 Error Unity Vuforia.Internal.Core.Engine:InitOnCameraReady()
2024/01/04 16:02:17.124 21431 21451 Error Unity Vuforia.Internal.Utility.ExtensionMethods.IEnumerableExtensionMethods:ForEach(IEnumerable`1, Action`1)
2024/01/04 16:02:17.124 21431 21451 Error Unity Vuforia.Internal.Core.Engine:Init(String)
2024/01/04 16:02:17.124 21431 21451 Error Unity Vuforia.Internal.Core.OneTimeInitialization:Initialize()
2024/01/04 16:02:17.124 21431 21451 Error Unity 
2024/01/04 16:02:17.330 21431 21451 Error Unity Vuforia Engine initialization failed: PLATFORM_ANDROID_CONFIG_INITIALIZATION_ERROR
2024/01/04 16:02:17.330 21431 21451 Error Unity 
2024/01/04 16:02:17.330 21431 21451 Error Unity PLATFORM ANDROID CONFIG INITIALIZATION ERROR
2024/01/04 16:02:17.330 21431 21451 Error Unity 
2024/01/04 16:02:17.330 21431 21451 Error Unity Failed to initialize Vuforia Engine.
2024/01/04 16:02:17.330 21431 21451 Error Unity UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
2024/01/04 16:02:17.330 21431 21451 Error Unity DefaultInitializationErrorHandler:SetErrorCode(VuforiaInitError)
2024/01/04 16:02:17.330 21431 21451 Error Unity DefaultInitializationErrorHandler:OnVuforiaInitializationError(VuforiaInitError)
2024/01/04 16:02:17.330 21431 21451 Error Unity System.Reflection.RuntimeMethodInfo:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
2024/01/04 16:02:17.330 21431 21451 Error Unity System.Delegate:DynamicInvokeImpl(Object[])
2024/01/04 16:02:17.330 21431 21451 Error Unity Vuforia.Utility.ExtensionMethods.DelegateHelper:InvokeDelegate(Delegate, Object[])
2024/01/04 16:02:17.330 21431 21451 Error Unity Vuforia.Utility.ExtensionMethods.DelegateHelper:InvokeWithExceptionHandling(Action`1, T)
2024/01/04 16:02:17.330 21431 21451 Error Unity 

Workaround Remove the camera permission after every run.

See also issue: https://github.com/PTCInc/vuforia-engine/issues/70 which was closed for not following the guidelines

ptc-emaggio commented 6 months ago

Is the issue reproducible on the Vuforia Engine core sample? https://assetstore.unity.com/packages/templates/packs/vuforia-core-samples-99026

ptc-epassaro commented 6 months ago

Hello @slabarque, thank you for the detailed report. The team was able to reproduce this issue and it is currently under investigation. We will keep you posted on the progress.

ptc-epassaro commented 6 months ago

Hello @slabarque, we have identified the source of the issue as the the new "Application Entry Point" PlayerSettings flags introduced in Unity 2023.1.

The problem only appears when the "Application Entry Point" is set to "GameActivity". Unfortunately, this is the default value for this flag in new Unity projects.

While we work on adding support for this new option, you could try to use the following workaround:

If you try this workaround, please let us know how it goes. We would really appreciate the feedback!

slabarque commented 6 months ago

I tried the workaround and it works. Thanks so much! Any idea when a permanent fix will be out?

ptc-epassaro commented 6 months ago

Glad to know that it works! The permanent fix will be part of the next release of Vuforia, but at the moment I don't have a time-frame for that. We'll update this thread when we have more information.

ptc-thesbyro commented 2 months ago

A fix for this issue was released with 10.25.4 and you should no longer have to manually set the Application Entry Point back to Activity when using Unity 2023.1+.

I'm, therefore, closing this tickets as fixed.