Android App crashes using Unity IAP 1.21.0

We are experiencing frequent crashes on our current Android release candidate for the Google Play Store.

We have isolated the commit and determined that it is indeed being caused by upgrading Unity IAP from 1.20.0 to 1.21.0. Rolling back to Unity IAP 1.20.0 fixes the issue.

It is only happening on our Android version of the app, targeting the Google Play Store (we do not publish to the Amazon App Store). It is not happening with our iOS App Store version of the app.

It occurs when lots of Sprites are being loaded and used. For example: during an end of level animation we render a particle explosion that uses a lot of Sprites; or when paging quickly through the userā€™s inventory which also loads a lot Sprites.

Itā€™s possible itā€™s related to higher memory usage, though we are not seeing the Application.LowMemory callback being triggered before the crash.

We are using Unity 2017.1.3p1

Iā€™m not seeing anything interesting in the verbose logs before just before the crash. Iā€™m only seeing what our app is logging.

19141 19177 W google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
19141 19177 W google-breakpad: Chrome build fingerprint:
19141 19177 W google-breakpad: 69.0.3497.86
19141 19177 W google-breakpad: 349708652
19141 19177 W google-breakpad: ### ### ### ### ### ### ### ### ### ### ### ### ###
19141 19177 F ious.wordgeniu: indirect_reference_table.cc:59] JNI ERROR (app bug): accessed stale Local 0x1 (index 0 in a table of size 0)
19141 19169 I Unity : TrackEvent: CardWalletScreenView.World:cubicle-life, [no data]
19141 19169 I Unity :
19141 19169 I Unity : (Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
19141 19169 I Unity :
19141 19177 F ious.wordgeniu: runtime.cc:558] Runtime abortingā€¦
19141 19177 F ious.wordgeniu: runtime.cc:558] Dumping all threads without appropriate locks held: thread list lock
19141 19177 F ious.wordgeniu: runtime.cc:558] All threads:
19141 19177 F ious.wordgeniu: runtime.cc:558] DALVIK THREADS (64):
19141 19177 F ious.wordgeniu: runtime.cc:558] ā€œThread-297ā€ prio=5 tid=64 Runnable
19141 19177 F ious.wordgeniu: runtime.cc:558] | group=ā€œā€ sCount=0 dsCount=0 flags=0 obj=0x13440000 self=0xc6a7dc00
19141 19177 F ious.wordgeniu: runtime.cc:558] | sysTid=19177 nice=0 cgrp=default sched=0/0 handle=0xca1ff970
19141 19177 F ious.wordgeniu: runtime.cc:558] | state=R schedstat=( 123416347 17754068 178 ) utm=4 stm=7 core=3 HZ=100
19141 19177 F ious.wordgeniu: runtime.cc:558] | stack=0xca100000-0xca102000 stackSize=1026KB
19141 19177 F ious.wordgeniu: runtime.cc:558] | held mutexes= ā€œabort lockā€ ā€œmutator lockā€(shared held)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #00 pc 002d975f /system/lib/libart.so (art::smile:umpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+134)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #01 pc 0036e98b /system/lib/libart.so (art::thread::smile:umpStack(std::__1::basic_ostream<char, std::__1::char_traits>&, bool, BacktraceMap*, bool) const+210)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #02 pc 0036b143 /system/lib/libart.so (art::thread::smile:ump(std::__1::basic_ostream<char, std::__1::char_traits>&, bool, BacktraceMap*, bool) const+34)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #03 pc 00383df9 /system/lib/libart.so (art::smile:umpCheckpoint::Run(art::Thread*)+624)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #04 pc 0037e0df /system/lib/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+314)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #05 pc 0037d65b /system/lib/libart.so (art::ThreadList::smile:ump(std::__1::basic_ostream<char, std::__1::char_traits>&, bool)+378)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #06 pc 0034d8fb /system/lib/libart.so (art::Runtime::Abort(char const*)+314)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #07 pc 000071b3 /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+494)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #08 pc 001b69b5 /system/lib/libart.so (art::IndirectReferenceTable::AbortIfNoCheckJNI(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator> const&)+172)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #09 pc 0023752f /system/lib/libart.so (art::IndirectReferenceTable::GetChecked(void*) const+270)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #10 pc 003731d7 /system/lib/libart.so (art::thread::smile:ecodeJObject(_jobject*) const+54)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #11 pc 003486ab /system/lib/libart.so (art::(anonymous namespace)::ArgArray::BuildArgArrayFromJValues(art::ScopedObjectAccessAlreadyRunnable const&, art::ObjPtrart::mirror::Object, jvalue*)+138)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #12 pc 00348533 /system/lib/libart.so (art::InvokeWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue*)+294)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #13 pc 0028599f /system/lib/libart.so (art::JNI::CallStaticObjectMethodA(_JNIEnv*, _jclass*, _jmethodID*, jvalue*)+446)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #14 pc 00aca514 /data/app/com.curious.wordgenius-ETCWu9Rc16npzlRhWeH7jg==/lib/arm/libunity.so (???)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #15 pc 0001481e anonymous:e622e000 (???)
19141 19177 F ious.wordgeniu: runtime.cc:558] (no managed stack frames)
<< OMITTED SEE ATTACHED LOGFILE >>
19141 19177 F ious.wordgeniu: runtime.cc:558]
19141 19177 F ious.wordgeniu: runtime.cc:558] Aborting thread:
19141 19177 F ious.wordgeniu: runtime.cc:558] | stack=0xca100000-0xca102000 stackSize=1026KB
19141 19177 F ious.wordgeniu: runtime.cc:558] | held mutexes= ā€œabort lockā€ ā€œmutator lockā€(shared held)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #01 pc 0036e98b /system/lib/libart.so (art::thread::smile:umpStack(std::__1::basic_ostream<char, std::__1::char_traits>&, bool, BacktraceMap*, bool) const+210)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #04 pc 0034db57 /system/lib/libart.so (art::Runtime::Abort(char const*)+918)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #05 pc 000071b3 /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+494)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #09 pc 003486ab /system/lib/libart.so (art::(anonymous namespace)::ArgArray::BuildArgArrayFromJValues(art::ScopedObjectAccessAlreadyRunnable const&, art::ObjPtrart::mirror::Object, jvalue*)+138)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #12 pc 00aca514 /data/app/com.curious.wordgenius-ETCWu9Rc16npzlRhWeH7jg==/lib/arm/libunity.so (???)
19141 19177 F ious.wordgeniu: runtime.cc:558] native: #13 pc 0001481e anonymous:e622e000 (???)
19141 19177 F libc : Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 19177 (Thread-297), pid 19141 (ious.wordgenius)
19468 19468 E DEBUG : failed to readlink /proc/19177/fd/145: No such file or directory
19468 19468 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
730 730 I /system/bin/tombstoned: received crash request for pid 19177
19468 19468 I crash_dump32: performing dump of process 19141 (target tid = 19177)
19468 19468 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
19468 19468 F DEBUG : Build fingerprint: ā€˜google/sailfish/sailfish:9/PPR2.180905.006/4945130:user/release-keysā€™
19468 19468 F DEBUG : Revision: ā€˜0ā€™
19468 19468 F DEBUG : ABI: ā€˜armā€™
19468 19468 F DEBUG : pid: 19141, tid: 19177, name: Thread-297 >>> com.curious.wordgenius <<<
19468 19468 F DEBUG : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
19468 19468 F DEBUG : Abort message: ā€˜indirect_reference_table.cc:59] JNI ERROR (app bug): accessed stale Local 0x1 (index 0 in a table of size 0)ā€™
19468 19468 F DEBUG : r0 00000000 r1 00004ae9 r2 00000006 r3 00000008
19468 19468 F DEBUG : r4 00004ac5 r5 00004ae9 r6 ca1fee2c r7 0000010c
19468 19468 F DEBUG : r8 00000000 r9 cdcbcfa7 r10 00000000 r11 ca1ff128
19468 19468 F DEBUG : ip ca1fedc8 sp ca1fee18 lr e8868f19 pc e8860d66
19468 19468 F DEBUG :
19468 19468 F DEBUG : backtrace:
19468 19468 F DEBUG : #00 pc 0001cd66 /system/lib/libc.so (abort+58)
19468 19468 F DEBUG : #01 pc 0034db4f /system/lib/libart.so (art::Runtime::Abort(char const*)+910)
19468 19468 F DEBUG : #02 pc 000071b3 /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+494)
19468 19468 F DEBUG : #03 pc 001b69b5 /system/lib/libart.so (art::IndirectReferenceTable::AbortIfNoCheckJNI(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator> const&)+172)
19468 19468 F DEBUG : #04 pc 0023752f /system/lib/libart.so (art::IndirectReferenceTable::GetChecked(void*) const+270)
19468 19468 F DEBUG : #05 pc 003731d7 /system/lib/libart.so (art::thread::smile:ecodeJObject(_jobject*) const+54)
19468 19468 F DEBUG : #06 pc 003486ab /system/lib/libart.so (art::(anonymous namespace)::ArgArray::BuildArgArrayFromJValues(art::ScopedObjectAccessAlreadyRunnable const&, art::ObjPtrart::mirror::Object, jvalue*)+138)
19468 19468 F DEBUG : #07 pc 00348533 /system/lib/libart.so (art::InvokeWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue*)+294)
19468 19468 F DEBUG : #08 pc 0028599f /system/lib/libart.so (art::JNI::CallStaticObjectMethodA(_JNIEnv*, _jclass*, _jmethodID*, jvalue*)+446)
19468 19468 F DEBUG : #09 pc 00aca514 /data/app/com.curious.wordgenius-ETCWu9Rc16npzlRhWeH7jg==/lib/arm/libunity.so
19468 19468 F DEBUG : #10 pc 0001481e anonymous:e622e000

3664852ā€“300211ā€“2018-09-11-unity_iap_crash.txt (89.1 KB)

Itā€™s worth noting that there is a similar JNI ERROR crash related to Unity IAP 1.21.0 reported in this thread .

However, that thread says the crash happens when the Unity IAP module is initialized.

We are able to initialize the Unity IAP module without causing a crash.

[mention|FoT1X6hnMLAUmFLAiyG1NQ==], you asked in this other thread , where people were complaining about problems with Android and Unity IAP 1.21.0, to open new threads.

Iā€™m having the same JNI ERROR that others are experiencing

Please let me know if there is any other information you need to help debug.

@jreed-curious Yes, please provide exact steps to reproduce using a minimal project that demonstrates differing behavior in 1.21 vs earlier versions. Bug reports unfortunately are not sufficient, we need steps to reproduce.

@JeffDUnity3D Sounds good. Iā€™ll put something together.

Alternatively, would providing you our crashing APK along with reproduction steps be sufficient?

@jreed-curious If you could provide a minimal project that reproduces the issue, that would suffice. But not just the APK.

@JeffDUnity3D Ok Iā€™ll put something together.

In the meantime, could you clarify what exactly was added in the Unity IAP 1.21.0 upgrade? The [release notes]( Unity IAP package 4.12.2 is now available page-2#post-3598466) are not informative:
Added
UDP module, currently in closed beta. We will provide more information soon. This release did not modify any other IAP functionality.

and Google isnā€™t turning up any useful docs for ā€œUnity UDPā€ (save for a couple mentions here and here).

It would be a huge help to me in creating a minimally reproducing project to know what exactly the UDP module does and why it would have an impact on an android app using IAP.

Thank you for your help!

It ā€œshouldā€ do nothing and should have no impact. It is for developers targeting various stores in China. You could start with this sample project here if that would help Sample IAP Project

1 Like

@jreed-curious Actually we may have found the issue, and we could indeed test with your APK with the steps to reproduce. Please private message me the info, if possible.

1 Like

Awesome!

My guess about the Sprites and memory pressure didnā€™t pan out in my test-app. There are so many different moving parts in our app (plugins, coroutines, etcā€¦) that its no small task to whittle it down to the bare essentials that cause the crash.

Iā€™ll get you a copy in a few hours and steps to reproduce in a few hours.

what was the result of this? I am seeing this in 2018.4.v32f1 still.

Please open a new thread with steps to reproduce, you are likely seeing something different. Also ensure to be using IAP 3.0.1 and provide the device logs.