Balaso-Software / app-tracking-transparency-for-unity

Later this year Apple will require your apps/games to request user's authorization in order to obtain the Identifier for Advertising (IDFA), used to optimize and maximize your Ads revenue
16 stars 1 forks source link

app crashes after request is done #20

Closed puerinferos closed 3 years ago

mrkaratechamp commented 3 years ago

I have the same issue, some updates here?

manelizzard commented 3 years ago

Hello @puerinferos, @mrkaratechamp.

Can you please share the deails of your crash: Unity Version, XCode version, iOS version, crash log, code causing the crash, etc...?

Thanks

Remstam commented 3 years ago

Hello @manelizzard

As the one who faced the issue described in the title I was able to reproduce it at your test app. If I try to send a simple GET UnityWebRequest inside OnAuthorizationRequestDone callback, this will lead to a crash immediately no matter which option has been chosen.

The request from Unity manual page to example.com is enough to reproduce.(https://docs.unity3d.com/2018.4/Documentation/ScriptReference/Networking.UnityWebRequest.Get.html)

Unity version: 2018.4.32 xCode version: 12.4 iOS version: 14.4.2

That is what Crashlytics says:

Fatal Exception: Il2CppExceptionWrapper

Crashed: com.google.firebase.crashlytics.ios.exception 0 UnityFirebaseTest 0x10512d7a0 FIRCLSProcessRecordAllThreads + 397 (FIRCLSProcess.c:397) 1 UnityFirebaseTest 0x10512db84 FIRCLSProcessRecordAllThreads + 428 (FIRCLSProcess.c:428) 2 UnityFirebaseTest 0x105127848 FIRCLSHandler + 34 (FIRCLSHandler.m:34) 3 UnityFirebaseTest 0x1051234e4 FIRCLSExceptionRecord_block_invoke + 218 (FIRCLSException.mm:218) 4 libdispatch.dylib 0x1b2b8b280 _dispatch_client_callout + 16 5 libdispatch.dylib 0x1b2b3ad6c _dispatch_lane_barrier_sync_invoke_and_complete + 56 6 UnityFirebaseTest 0x105122c7c FIRCLSExceptionRecord + 225 (FIRCLSException.mm:225) 7 UnityFirebaseTest 0x1051229c4 FIRCLSTerminateHandler() + 295 (FIRCLSException.mm:295) 8 libc++abi.dylib 0x1c6874154 std::terminate(void (*)()) + 16 9 libc++abi.dylib 0x1c68740ec std::terminate() + 44 10 libobjc.A.dylib 0x1c6778ee8 _objc_terminate() + 10 11 libdispatch.dylib 0x1b2b8b314 _dispatch_client_callout3 + 36 12 libdispatch.dylib 0x1b2b4635c _dispatch_mach_msg_async_reply_invoke$VARIANT$mp + 352 13 libdispatch.dylib 0x1b2b3ddd0 _dispatch_kevent_worker_thread + 1188 14 libsystem_pthread.dylib 0x1f7b985dc _pthread_wqthread + 328 15 libsystem_pthread.dylib 0x1f7b9b874 start_wqthread + 8`

Though it is not that obvious to understand what is going on.

Remstam commented 3 years ago

It seems it is not safe to launch OnAuthorizationRequestDone as is (can lead to non-main thread execution I guess as ATT works async deep down iOS side), it is better to remember sync context before request tracking and post OnAuthorizationRequestDone into that context.

That approach make crash disappear, but I will test a little bit more to be sure enough that was the thing.

SanderPaladin commented 3 years ago

We had this same issue, we can prevent the crash by using the MonoBehaviour event OnApplicationPause (false) as the callback instead of the one provided by the plugin and leaving OnAuthorizationRequestDone empty.

iserofeev commented 3 years ago

I faced this problem, but it only reproduces on development builds

manelizzard commented 3 years ago

Hello @iserofeev @SanderPaladin @Remstam @mrkaratechamp,

We have fixed the issue in the brand new version v2.3: https://assetstore.unity.com/packages/tools/integration/app-tracking-transparency-for-unity-ios-14-idfa-174256

Should not crash anymore as the callback has been forced to happen in Unity's Main Thread.

Thanks all for your input and feedback.

Best