google-ar / arcore-unity-extensions

Google ARCore Extensions and Geospatial Creator for Unity's AR Foundation
Other
333 stars 94 forks source link

Segmentation fault on app startup #182

Open puddleglum56 opened 3 months ago

puddleglum56 commented 3 months ago

I've been struggling for the past few weeks to get an iOS build with ARCore Unity Extensions working, but I seem to always get a segmentation fault immediately on app startup.

Unity version: 2022.3.21f1 iOS version: 17.4 ARCore Extensions version: 1.41.0

App logs

I tried to make an MRE, and it seems like I can narrow it down to a blank Unity 3D project with a Firebase pod dependency.

Minimal repro Xcode project folder Minimal repro deployment folder ARCore extensions and Firebase fully configured project ipa

If needed, I can share the fully configured Unity project folder later today.

15kingben commented 3 months ago

Does the crash happen when using just firebase or when firebase and ARCore are used together? ARCore has some firebase dependencies, you may want to try using just a single target/version like the iOS CloudAnchorExample does and see if the crash is still reproducible: https://github.com/google-ar/arcore-ios-sdk/blob/master/Examples/CloudAnchorExample/Podfile#L5

puddleglum56 commented 3 months ago

Thanks for getting back to me. Sorry about the delay in responding. I believe the crash has happened with just Firebase, though I don't remember if it was a blank Unity project.

I built a blank Unity project for iOS and added the the dependencies from Podfile you linked from the CloudAnchorExample. This is the Podfile I used:

source 'https://cdn.cocoapods.org/'

platform :ios, '12.0'

target 'UnityFramework' do
  pod 'ARCore/CloudAnchors', '~> 1.41.0'
  pod 'Firebase/Database', '~> 8.0'
end
target 'Unity-iPhone' do
end
use_frameworks! :linkage => :static

I installed pods, and built and deployed via Xcode. This app opens fine, gets past the Unity splash screen, and shows the blank scene.

I then tried copying the blank built Unity project directory, and made no changes except replacing the ARCore dependency with the Geospatial one. This is what this Podfile looked like:

source 'https://cdn.cocoapods.org/'

platform :ios, '12.0'

target 'UnityFramework' do
  pod 'ARCore/Geospatial', '~> 1.41.0'
  pod 'Firebase/Database', '~> 8.0'
end
target 'Unity-iPhone' do
end
use_frameworks! :linkage => :static

I then installed the pods, built, and deployed via Xcode. This app crashes due to a segmentation fault on startup. This seems to indicate that there is a problem with Geospatial and/or its dependencies, as that is the only thing I changed between the working app and the crashing one.

In case it's useful, I uploaded both Xcode build directories to Google Drive. With CloudAnchor With Geospatial

I also uploaded the built ipas

Are you able to reproduce the crash?

puddleglum56 commented 2 months ago

@15kingben is there any more information you need to help me debug this? I would love to be able to deploy to iOS but currently I am forced to develop on Android

15kingben commented 2 months ago

Hi @puddleglum56, sorry for the delay. I was able to reproduce the crash from your Xcode workspace, for me the crash happens predictably at StringStorageDefaults in profiler_initialize. (From your stack trace it looks like you hit the error in a different location?) I tried asan and some other Xcode options but that did not yield anything useful. There are some similar issues online but nothing that close.

My guess would be some kind of memory corruption bug, although I don't know why it would manifest with Geospatial and not with Cloud Anchors. Can you try disabling the profiling option in the Unity build settings, or perhaps try with a different Unity version?

Screenshot 2024-04-09 at 10 39 59 AM
puddleglum56 commented 2 months ago

Thanks for getting back. Maybe you have some different profiler settings that are causing a different error for you?

In any case, I didn't have profiling enabled in the Unity build settings when I built, so no fix there. I tried Unity version 2021.3.37f1 (the LTS version) and...it works! I successfully get past the Unity splash screen with no error, and can build and deploy the Geospatial sample!

Thank you for your help! That said, it would be nice if the bug could be fixed for the 2022 LTS version, since the 2021 LTS version is reaching end-of-life this year. I'll now have to back port my game to the previous LTS version. I anticipate many developers who are trying out ARCore Geospatial will also start with the 2022 LTS version.

swardle commented 2 months ago

The one thing that is different between Geospatial and Cloud Anchors, is Geospatial sample uses the GPS (Input.location). This does not work with new input on android anyways. I wonder if the project is getting auto updated to the new input system. If so maybe we just need "Active Input Handling" to "Both"? I have read that iOS does not have this issue https://forum.unity.com/threads/location-gps-tracking-with-new-input-system.1090213/ but on android this is a known issue for us on the Unity side.

puddleglum56 commented 2 months ago

Hi @swardle the crashing build I provided is just a blank Unity 3D project, not the Geospatial sample. I'm not sure if that would make a difference. After building the Unity project, I manually added a minimal Podfile (noted above) with the respective ARCore dependencies, installed the dependencies, and built in XCode.

Also, when I was attempting to build the Geospatial sample for iOS (before making the minimal repro for this issue), I always set 'Active Input Handling' to 'Both' and I was still getting crashes on app startup.

devbridie commented 2 months ago

Hey, We've asked our friends at Unity to help take a look at this as the stack trace isn't very helpful.

puddleglum56 commented 2 months ago

Thanks. Let me know if I can provide any additional information. Were you guys able to repro with a fresh blank Unity 2022 LTS build on your side?

puddleglum56 commented 1 month ago

Hi all, just checking in to see if there's been any progress on this. I've been moving forward with Unity 2021 LTS but I'd love to be able to upgrade if need be.