Android crash at Snowplow initialization (Unity)

Hello,

I’m using Snowplow Unity Tracker (0.8.0) with Unity 2021.3.0f1.
On some Android devices, I’ve a crash at launch (snowplow initialization):

  • samsung j6lte - android 10 (sdk 29)
  • samsung m11q - android 12 (sdk 31)
  • maybe others…

On the Google Play Console, I have retrieved this stack trace:

#00 pc 0x0000000000f2bf60 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (BufferExtensions_ToBytes_mD4A52CF73A682C06EE82547488AFD6770004CABA)
#01 pc 0x000000000023de3c /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (Action_3_Invoke_mEA633800799B21E5D3131688570818A85B88BBE8_Open(Action_3_tA8FEE621E41DEB497362AFB07992905C4D31FFFF*, long long, Il2CppObject*, int, MethodInfo const*))
#02 pc 0x0000000000b9719c /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (Action_3_Invoke_mEA633800799B21E5D3131688570818A85B88BBE8_gshared)
#03 pc 0x0000000000945820 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (BufferWriter_WriteNumber_TisInt64_t092CFB123BE63C28ACDAF65C68F21A526050DBA3_m6407ACA07C1C40765A5299C762E6325D5BB632D0_gshared)
#04 pc 0x000000000101fbe0 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (BufferWriter_Write_mDC1A9597CD8014C7F9198227D3CB010FD37C660A)
#05 pc 0x0000000001020b28 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (BufferWriter_WriteElement_m460D3E82F4EB5415394EE92FEAF60DEF2DE6F586)
#06 pc 0x0000000001020dac /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (BufferWriter_WriteDocument_m3936C547831278B318CC86DE58AAEAE59BFEF359)
#07 pc 0x0000000000d60cec /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (DataService_Insert_mDA4B902F9CA4267C8E3AEE7F516A8D3206C6D843)
#08 pc 0x0000000001028350 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (LiteEngine_InsertDocument_m94ADC47B7A7965CED95784FCF31B29602DD95B91)
#09 pc 0x0000000001031590 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (U3CU3Ec__DisplayClass7_0_U3CInsertU3Eb__0_mE9A78FB5C63C2443F67BAD5217DFEC2A0F666B7E)
#10 pc 0x0000000000784990 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (LiteEngine_AutoTransaction_TisInt32_t680FF22E76F6EFAD4375103CBBFFA0421349384C_m31D11897108F0759A06DA2B2C29AB1443B6F74EF_gshared)
#11 pc 0x00000000004d8000 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (LiteCollection_1_Insert_m7F8AFC62D89C979B4ABBB866212C2BA7B4FC56F2_gshared)
#12 pc 0x0000000000970b44 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (EventStore_AddEvent_m4E69A630B161A75CD167B1F98008D918F76848CF)
#13 pc 0x000000000097d640 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (AsyncEmitter_EventConsumer_m42038601C44DBD2E3C9D7B5774ECEE389FE6E50C)
#14 pc 0x00000000006ce4f4 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (ExecutionContext_RunInternal_mFA922C000D78E36A9A994FFEA9493DA20240BB64)
#15 pc 0x00000000006c9b44 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (ExecutionContext_Run_m644C20717BCF653C14B8F6FDF9CFF70BBA41C1F1)
#16 pc 0x00000000004065e0 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (il2cpp::vm::Runtime::InvokeWithThrow(MethodInfo const*, void*, void**))
#17 pc 0x000000000040642c /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**))
#18 pc 0x0000000000480e8c /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (il2cpp::icalls::mscorlib::System::Threading::ThreadStart(void*))
#19 pc 0x0000000000460a6c /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (il2cpp::os::thread::RunWrapper(void*))
#20 pc 0x000000000045b6b8 /data/app/~~n3K2oErJQDB8JrxhmPBmuQ==/com.XXXXXXXX-Y0E5xIFHrxC0ecqSLjQ0-A==/lib/arm/libil2cpp.so (il2cpp::os::ThreadImpl::ThreadStartWrapper(void*))
#21 pc 0x00000000000aec5f /apex/com.android.runtime/lib/bionic/libc.so (pthread_attr_getdetachstate)

I’ve seen that there is “EventStore_AddEvent” and “AsyncEmitter” which are Snowplow unity tracker terms. Also I know that Snowplow Unity tracker use LiteDB…
So I’ve removed the SDK initialization, test the application again, and no more crash!
I think it doesn’t depend on the android version because I’ve tested on other devices with the same android version but there was no crash.

My question is, do you have an idea on what could be the problem, and do you think I have something to do to fix this issue? or something to do on unity tracker?

If you need more information, don’t hesitate to ask me.

Thank you in advance

Hi @Lampik, thanks for reporting this!

It’s hard to understand the exact problem with the database access from the logs, but it seems to be related to this open issue on the LiteDB database that we use. It seems to have been reported in 2020 with no progress unfortunately. We will look into if we can avoid it somehow, if you have any suggestions, please let us know!

One workaround would be to use the in-memory storage option as an event store instead of writing events to a local database. The downside of this is that events that fail to be sent before the app quits (e.g., because of lack internet connectivity) will be lost (when using the SQLite event store, they are sent the next time the app starts).

You will need to pass an instance of the InMemoryEventStore when initializing the AsyncEmitter:

using SnowplowTracker.Emitters;
using SnowplowTracker.Storage;

IStore eventStore = new InMemoryEventStore();
IEmitter emitter = new AsyncEmitter(
   "com.collector.acme",
   HttpProtocol.HTTPS,
   HttpMethod.POST,
   500,
   52000,
   52000,
   eventStore
);

Hope this helps!

1 Like

Thank you @matus for your suggestion, I think it could be a solution in my case.