artoolkitx / arunityx

artoolkitX for Unity, providing high-performance video acquisition, marker and texture tracking and full Unity Editor support
https://www.artoolkitx.org/
Other
41 stars 22 forks source link

Building on iOS still not possible #71

Closed EtharBuildBot closed 1 year ago

EtharBuildBot commented 1 year ago

When building in Unity for iOS an issue is raised (see below) however a build is still generated:

'''text EntryPointNotFoundException: arwRegisterLogCallback assembly: type: member:(null) PluginFunctionsARX.arwRegisterLogCallback (PluginFunctionsLogCallback lcb) (at Assets/artoolkitX-Unity/Scripts/PluginFunctionsARX.cs:106) ARController.OnEnable () (at Assets/artoolkitX-Unity/Scripts/ARController.cs:425) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:189) '''

However, when trying to build using Xcode on Mac, the screen simply renders pink and no camera feed is displayed:

'''iOS log 2023-05-15 16:53:46.604864+0100 ARUnityX-Test[1175:347132] Built from '2021.3/staging' branch, Version '2021.3.24f1 (cf10dcf7010d)', Build type 'Release', Scripting Backend 'il2cpp' 2023-05-15 16:53:46.606003+0100 ARUnityX-Test[1175:347132] MemoryManager: Using 'Default' Allocator. [UnityMemory] Configuration Parameters - Can be set up in boot.config "memorysetup-bucket-allocator-granularity=16" "memorysetup-bucket-allocator-bucket-count=8" "memorysetup-bucket-allocator-block-size=4194304" "memorysetup-bucket-allocator-block-count=1" "memorysetup-main-allocator-block-size=16777216" "memorysetup-thread-allocator-block-size=16777216" "memorysetup-gfx-main-allocator-block-size=16777216" "memorysetup-gfx-thread-allocator-block-size=16777216" "memorysetup-cache-allocator-block-size=4194304" "memorysetup-typetree-allocator-block-size=2097152" "memorysetup-profiler-bucket-allocator-granularity=16" "memorysetup-profiler-bucket-allocator-bucket-count=8" "memorysetup-profiler-bucket-allocator-block-size=4194304" "memorysetup-profiler-bucket-allocator-block-count=1" "memorysetup-profiler-allocator-block-size=16777216" "memorysetup-profiler-editor-allocator-block-size=1048576" "memorysetup-temp-allocator-size-main=4194304" "memorysetup-job-temp-allocator-block-size=2097152" "memorysetup-job-temp-allocator-block-size-background=1048576" "memorysetup-job-temp-allocator-reduction-small-platforms=262144" "memorysetup-temp-allocator-size-background-worker=32768" "memorysetup-temp-allocator-size-job-worker=262144" "memorysetup-temp-allocator-size-preload-manager=262144" "memorysetup-temp-allocator-size-nav-mesh-worker=65536" "memorysetup-temp-allocator-size-audio-worker=65536" "memorysetup-temp-allocator-size-cloud-worker=32768" "memorysetup-temp-allocator-size-gfx=262144" -> applicationDidFinishLaunching() [Subsystems] Discovering subsystems at path /private/var/containers/Bundle/Application/E51E28F0-7AD3-4351-B52B-0FD87BE9E433/ARUnityX-Test.app/Data/UnitySubsystems GfxDevice: creating device client; threaded=1; jobified=0 Initializing Metal device caps: Apple A12Z GPU Initialize engine version: 2021.3.24f1 (cf10dcf7010d) -> applicationDidBecomeActive() 2023-05-15 16:53:47.773771+0100 ARUnityX-Test[1175:347132] Unbalanced calls to begin/end appearance transitions for <UnityDefaultViewController: 0x104c54090>. UnloadTime: 3.340292 ms ARController: ARController.Awake()) ARController:Awake()

ARController: ARController.OnEnable() ARController:OnEnable()

2023-05-15 16:53:51.835946+0100 ARUnityX-Test[1175:347132] [info] artoolkitX v1.1.7 initalised. ARController: artoolkitX version 1.1.7 initialised. ARController: ARController.Start(): Application.isPlaying = True autoStart: True ARController:Start()

ARController: Starting AR.

d__111:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) ARController:Start() ARController: Render device: Metal, using Unity texturing. d__111:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) ARController:Start() ARController: Starting artoolkitX video with vconf '-module=AVFoundation -preset=medium'. d__111:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) ARController:Start() 2023-05-15 16:53:51.852704+0100 ARUnityX-Test[1175:347132] [info] Starting... 2023-05-15 16:53:51.852761+0100 ARUnityX-Test[1175:347132] [info] Setting video configuration '-module=AVFoundation -preset=medium'. 2023-05-15 16:53:51.852781+0100 ARUnityX-Test[1175:347132] [info] Opening artoolkitX video using configuration '-module=AVFoundation -preset=medium'. 2023-05-15 16:53:51.852940+0100 ARUnityX-Test[1175:347132] [info] Using supplied video config "-module=AVFoundation -preset=medium". 2023-05-15 16:53:51.853023+0100 ARUnityX-Test[1175:347132] [info] Requesting capture session preset 'medium'. 2023-05-15 16:53:51.858763+0100 ARUnityX-Test[1175:347132] [info] Created new camera parameters database. ARController: Setting artoolkitX tracking settings. d__111:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) ARController:Start() AROrigin: Found 2 trackables eligible to become base trackable. AROrigin:FindTrackables() ARController: UpdateAR: Waiting for artoolkitX video. ARController:UpdateAR() 2023-05-15 16:53:52.305330+0100 ARUnityX-Test[1175:347132] [info] Waiting for video source. 2023-05-15 16:53:52.306331+0100 ARUnityX-Test[1175:347132] [info] Loading image data /private/var/containers/Bundle/Application/E51E28F0-7AD3-4351-B52B-0FD87BE9E433/ARUnityX-Test.app/Data/Raw/pinball.jpg. 2023-05-15 16:53:52.318082+0100 ARUnityX-Test[1175:347132] [info] First 2D marker trackable added; enabling 2D marker tracker. 2023-05-15 16:53:52.318108+0100 ARUnityX-Test[1175:347132] [info] Added trackable (UID=0), total trackables loaded: 1. 2023-05-15 16:53:52.318194+0100 ARUnityX-Test[1175:347132] [info] Loading image data /private/var/containers/Bundle/Application/E51E28F0-7AD3-4351-B52B-0FD87BE9E433/ARUnityX-Test.app/Data/Raw/gibraltar.jpg. 2023-05-15 16:53:52.335292+0100 ARUnityX-Test[1175:347132] [info] Added trackable (UID=1), total trackables loaded: 2. -> applicationWillResignActive() ARController: Stopping AR. ARController:StopAR() ARController:OnApplicationPause(Boolean) 2023-05-15 16:53:52.831014+0100 ARUnityX-Test[1175:347132] [info] Closing artoolkitX video. Unloading 4 Unused Serialized files (Serialized files now loaded: 0) -> applicationDidBecomeActive() Unloading 2 unused Assets to reduce memory usage. Loaded Objects now: 1937. Total: 2.018666 ms (FindLiveObjects: 0.203208 ms CreateObjectMapping: 0.119459 ms MarkObjects: 1.625916 ms DeleteObjects: 0.069041 ms) ARController: Starting AR. d__111:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) ARController:OnApplicationPause(Boolean) ARController: Render device: Metal, using Unity texturing. d__111:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) ARController:OnApplicationPause(Boolean) ARController: Starting artoolkitX video with vconf '-module=AVFoundation -preset=medium'. d__111:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) ARController:OnApplicationPause(Boolean) 2023-05-15 16:53:54.115776+0100 ARUnityX-Test[1175:347132] [info] Starting... 2023-05-15 16:53:54.115836+0100 ARUnityX-Test[1175:347132] [info] Setting video configuration '-module=AVFoundation -preset=medium'. 2023-05-15 16:53:54.115869+0100 ARUnityX-Test[1175:347132] [info] Opening artoolkitX video using configuration '-module=AVFoundation -preset=medium'. 2023-05-15 16:53:54.115899+0100 ARUnityX-Test[1175:347132] [info] Using supplied video config "-module=AVFoundation -preset=medium". 2023-05-15 16:53:54.116224+0100 ARUnityX-Test[1175:347132] [info] Requesting capture session preset 'medium'. ARController: Setting artoolkitX tracking settings. d__111:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) ARController:OnApplicationPause(Boolean) ARController: UpdateAR: Waiting for artoolkitX video. ARController:UpdateAR() 2023-05-15 16:53:54.358372+0100 ARUnityX-Test[1175:347132] [info] Waiting for video source. 2023-05-15 16:53:54.391894+0100 ARUnityX-Test[1175:347132] [info] Opened artoolkitX video 480x360@1Bpp (AR_PIXEL_FORMAT_420f). 2023-05-15 16:53:54.392066+0100 ARUnityX-Test[1175:347132] [info] No predefined camera parameters for device iPad (Unknown model). 2023-05-15 16:53:54.392136+0100 ARUnityX-Test[1175:347132] [info] Fetching external camera parameters. 2023-05-15 16:53:54.392164+0100 ARUnityX-Test[1175:347631] [info] cparamSearch beginning search for apple/iPad/iPad8,9, camera 0, aspect ratio 4:3. 2023-05-15 16:53:55.398801+0100 ARUnityX-Test[1175:347631] [warning] Using default camera parameters for 480x360 image size, 45 degrees vertical field-of-view. 2023-05-15 16:53:55.473304+0100 ARUnityX-Test[1175:347132] [info] Video source is running. (Waited 33 calls.) 2023-05-15 16:53:55.506745+0100 ARUnityX-Test[1175:347132] [info] Loading 2D data. [ WARN:0] global /Users/phil/r/opencv-git/modules/core/src/parallel/parallel.cpp (80) createParallelForAPI core(parallel): can't initialize ONETBB backend: OpenCV(4.5.2-pre) /Users/phil/r/opencv-git/modules/core/src/parallel/parallel.cpp:66: error: (-215:Assertion failed) info.backendFactory in function 'createParallelForAPI' [ WARN:0] global /Users/phil/r/opencv-git/modules/core/src/parallel/parallel.cpp (80) createParallelForAPI core(parallel): can't initialize TBB backend: OpenCV(4.5.2-pre) /Users/phil/r/opencv-git/modules/core/src/parallel/parallel.cpp:66: error: (-215:Assertion failed) info.backendFactory in function 'createParallelForAPI' [ WARN:0] global /Users/phil/r/opencv-git/modules/core/src/parallel/parallel.cpp (80) createParallelForAPI core(parallel): can't initialize OPENMP backend: OpenCV(4.5.2-pre) /Users/phil/r/opencv-git/modules/core/src/parallel/parallel.cpp:66: error: (-215:Assertion failed) info.backendFactory in function 'createParallelForAPI' 2023-05-15 16:53:55.605595+0100 ARUnityX-Test[1175:347132] [info] 2D marker added. 2023-05-15 16:53:55.605648+0100 ARUnityX-Test[1175:347132] [info] '/private/var/containers/Bundle/Application/E51E28F0-7AD3-4351-B52B-0FD87BE9E433/ARUnityX-Test.app/Data/Raw/pinball.jpg' assigned page no. 0. 2023-05-15 16:53:55.667254+0100 ARUnityX-Test[1175:347132] [info] 2D marker added. 2023-05-15 16:53:55.667300+0100 ARUnityX-Test[1175:347132] [info] '/private/var/containers/Bundle/Application/E51E28F0-7AD3-4351-B52B-0FD87BE9E433/ARUnityX-Test.app/Data/Raw/gibraltar.jpg' assigned page no. 1. 2023-05-15 16:53:55.667306+0100 ARUnityX-Test[1175:347132] [info] Loading of 2D data complete. ARController: UpdateAR: artoolkitX video is running. Configuring Unity scene for video. ARController:UpdateAR() ARController: Video 480x360@1Bpp (AR_PIXEL_FORMAT_420f) ARController:UpdateAR() ARController: Projection matrix: [ 1.81444 0.00000 -0.00209 0.00000 0.00000 2.42094 0.00279 0.00000 0.00000 0.00000 -1.00401 -0.02004 0.00000 0.00000 -1.00000 0.00000] ARController:UpdateAR() ARController: Video size 480x360 will use texture size 480x360. ARController:CreateVideoBackgroundMesh(Int32, Int32, Int32, Int32, Color[]&, Color32[]&, Texture2D&, Material&) ARController:UpdateAR() ARController: For 2388x1668 screen, calculated viewport 2224x1668 at (82, 0). ARController:getViewport(Int32, Int32, Boolean, ViewEye) ARController:ConfigureViewports() ARController:UpdateAR() ARController: For 2388x1668 screen, calculated viewport 2224x1668 at (82, 0). ARController:getViewport(Int32, Int32, Boolean, ViewEye) ARController:ConfigureViewports() ARController:UpdateAR() ARController: ScreenOrientation.LandscapeLeft ARController:UpdateVideoTexture() ARController:UpdateAR() ARController: For 2388x1668 screen, calculated viewport 2224x1668 at (82, 0). ARController:getViewport(Int32, Int32, Boolean, ViewEye) ARController:UpdateVideoTexture() ARController:UpdateAR() ARController: For 2388x1668 screen, calculated viewport 2224x1668 at (82, 0). ARController:getViewport(Int32, Int32, Boolean, ViewEye) ARController:UpdateVideoTexture() ARController:UpdateAR() ARController: Scene configured for video. ARController:UpdateAR() '''
philip-lamb commented 1 year ago

I was plagued by this error (EntryPointNotFoundException) for a day and now after updating Unity to 2021.3.25f1 I can't reproduce it. What version are you using?

philip-lamb commented 1 year ago

Closing as not able to be reproduced with current build.

philip-lamb commented 1 year ago

OK, so it looks like conditions for this to be triggered include updating the native iOS plugin after doing at least one previous build. Clearing the Unity project Library folder resolved the issue. So I would speculate that Unity is doing some caching of plugin symbols on iOS, and when the libARX.a file changes, it can't find the new symbol addresses using the old cache.

philip-lamb commented 1 year ago

This turned out to be a bug that was triggered by some recent version of Unity changing how it handles calls to plugin functions when iOS is selected. Fixed by #76