CartoDB / mobile-sdk

CARTO Mobile SDK core project
https://carto.com/docs/carto-engine/mobile-sdk/
BSD 3-Clause "New" or "Revised" License
185 stars 67 forks source link

Runtime Error just on Android 10 #422

Closed mastermobin closed 3 years ago

mastermobin commented 3 years ago

Hi

Recently, I see many crashes with the title of "abort" on Google Play Console just on android 10. you can see a part of backtrace below:

backtrace:

00 pc 00000000000830f0 /apex/com.android.runtime/lib64/bionic/libc.so (abort+160)

00 pc 00000000004b9614 /apex/com.android.runtime/lib64/libart.so (art::Runtime::Abort(char const*)+2280)

00 pc 000000000000b458 /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+580)

00 pc 00000000002a17ac /apex/com.android.runtime/lib64/libart.so (art::IndirectReferenceTable::AbortIfNoCheckJNI(std::1::basic_string<char, std::__1::char_traits, std::1::allocator> const&)+236)

00 pc 000000000037ee98 /apex/com.android.runtime/lib64/libart.so (art::IndirectReferenceTable::GetChecked(void*) const+432)

00 pc 00000000004ff0b0 /apex/com.android.runtime/lib64/libart.so (art::Thread::DecodeJObject(_jobject*) const+88)

00 pc 000000000038768c /apex/com.android.runtime/lib64/libart.so (art::JNI::IsSameObject(_JNIEnv, _jobject, _jobject*)+596)

00 pc 0000000000406674 /data/app/org.mobin.myapp-8YMO9wX9MYo0U6eEDjKGIw==/lib/arm64/libcarto_mobile_sdk.so!libcarto_mobile_sdk.so (offset 0x210000) (Java_com_carto_datasources_TileDataSourceModuleJNI_TileDataSource_1director_1connect+232)

00 pc 0000000000121b94 /data/app/org.mobin.myapp-8YMO9wX9MYo0U6eEDjKGIw==/oat/arm64/base.odex (art_jni_trampoline+196)

00 pc 00000000001428d0 /data/app/org.mobin.myapp-8YMO9wX9MYo0U6eEDjKGIw==/oat/arm64/base.odex (com.carto.datasources.TileDataSource.+96)

00 pc 000000000044c408 /data/app/org.mobin.myapp-8YMO9wX9MYo0U6eEDjKGIw==/oat/arm64/base.odex (o.c.a.m.d.+88)

00 pc 00000000003f9580 /data/app/org.mobin.myapp-8YMO9wX9MYo0U6eEDjKGIw==/oat/arm64/base.odex (o.c.a.m.f.u0.i0+224)

00 pc 0000000000402e70 /data/app/org.mobin.myapp-8YMO9wX9MYo0U6eEDjKGIw==/oat/arm64/base.odex (o.c.a.m.f.u0.j0+48)

How should I overcome this spreading issue?

Thank you

mtehver commented 3 years ago

We have not seen any reports like this before. Any idea how to reproduce the issue? The log definitely points to CARTO SDK but the parts it refers have not changed in years.

mastermobin commented 3 years ago

It may be related to the NDK version that I used to build CartoDB Mobile SDK. Is there any preferences about NDK version? I don't remember the NDK version that I used, all I know is that it was higher than minimum requirement.

mastermobin commented 3 years ago

I used NDK 20.1.5948944 in order to build CartoDB Mobile SDK (using Gradle 6.7.1), is there any problems with it?

mtehver commented 3 years ago

Our latest releases use NDK 21, but I do not think that the issue is caused by an older NDK. If you build your own version of the SDK, remember to re-generate proxies/wrappers using 'swigpp-java' after updating the code and before running 'build-android' script. If the wrappers and SDK native parts are out of sync, then strange errors like the one above may happen.

mastermobin commented 3 years ago

Tracing the crash, I found the reason in SwigDirector_TileDataSource::swig_connect_director. There is a race condition in SWIG code, so my app which is using multiple threads for initializing the tile data sources leads to a native crash because of this race condition. Afterwards, I found a related issue to my problem in Swig repository, which is solved and closed. Updating some of swig files may be helpful. Thank you :D

mastermobin commented 3 years ago

I've fixed this issue in swig by changing java.cxx and director.swg which is embedded in CartoDB::mobile-sdk based on suggested changes by main swig repository. I will submit a PR about it.

mtehver commented 3 years ago

Thanks for tracking this down! No need for PR, I have fixed it locally already, will push the changes tomorrow.

mastermobin commented 3 years ago

Thanks a lot :D