I'm using Marketing Cloud SDK (Mobile Push) v6.1.0 But I'm receiving a lot of ANRs as observed on Google Play Store performance reports. ANR is observed while we are reading InboxMessages using following API during app start:-


ANR Stacktrace :-

"main" tid=1 Runnable 
"main" prio=5 tid=1 Runnable
  | group="main" sCount=0 dsCount=0 flags=0 obj=0x71474d98 self=0x723f1ff000
  | sysTid=22382 nice=-4 cgrp=default sched=0/0 handle=0x7240751ed0
  | state=R schedstat=( 28831282988 8928373669 6515 ) utm=2720 stm=161 core=0 HZ=100
  | stack=0x7ffe4fa000-0x7ffe4fc000 stackSize=8192KB
  | held mutexes= "mutator lock"(shared held)
  #00  pc 0000000000412794  /apex/com.android.runtime/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+140)
  #01  pc 00000000004f9c5c  /apex/com.android.runtime/lib64/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+508)
  #02  pc 000000000051429c  /apex/com.android.runtime/lib64/libart.so (art::DumpCheckpoint::Run(art::Thread*)+812)
  #03  pc 00000000004fa98c  /apex/com.android.runtime/lib64/libart.so (art::Thread::RunCheckpointFunction()+176)
  #04  pc 00000000005922a8  /apex/com.android.runtime/lib64/libart.so (art::JniMethodFastEndWithReference(_jobject*, unsigned int, art::Thread*)+68)
  at java.lang.Throwable.nativeFillInStackTrace (Native method)
  at java.lang.Throwable.fillInStackTrace (Throwable.java:799)
- locked <0x0e99555f> (a java.lang.IllegalStateException)
  at java.lang.Throwable.<init> (Throwable.java:277)
  at java.lang.Exception.<init> (Exception.java:66)
  at java.lang.RuntimeException.<init> (RuntimeException.java:62)
  at java.lang.IllegalStateException.<init> (IllegalStateException.java:55)
  at com.salesforce.marketingcloud.messages.inbox.InboxMessage$Media.create (unavailable)
  at com.salesforce.marketingcloud.d.a.c.a (unavailable)
  at com.salesforce.marketingcloud.d.a.c.b (unavailable)
  at com.salesforce.marketingcloud.d.a.c.a (unavailable)
  at com.salesforce.marketingcloud.messages.inbox.d.getMessages (unavailable)
  at com.salesforce.marketingcloud.messages.inbox.c.getMessages (unavailable)
  at com.example.myapp.common.notification.MyNotificationHelper.getInboxMessages (MyNotificationHelper.kt:227)
  at com.example.myapp.common.notification.MyNotificationHelper.getUnreadMessageCount (MyNotificationHelper.kt:36)
  at com.example.myapp.common.notification.MyNotificationHelper.updateNotificationBadgeCount (MyNotificationHelper.kt:54)
  at com.example.myapp.MyApplication.onCreate (GBClosetApplication.java:127)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1189)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6460)
  at android.app.ActivityThread.access$1300 (ActivityThread.java:219)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1859)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:214)
  at android.app.ActivityThread.main (ActivityThread.java:7356)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:930)

This issue has been resolved as of version 6.2.2 of the SDK. Please update to at least that version or greater. Current is 6.3.4 as of 2019-09-25.

Something else of note in your question; getInstance() is a thread blocking call. It is probably a better idea to use requestSdk() in almost every imaginable scenario. This will almost certainly resolve your issue as well.

  • Issue still persist in 6.3.4. We uploaded app to play store 2 days back, and I received 1 ANR with same stacktrace on my latest app version – charlie Oct 18 '19 at 6:28
  • if (TextUtils.isEmpty(url) && TextUtils.isEmpty(altText)) { throw new IllegalStateException("Invalid media provided."); } Based on the error you're receiving I suspect either the URL is invalid and there is no AltText for your message. This is thrown in the InboxMessage.Media.create() method. – Bill Mote Oct 18 '19 at 14:34
  • I'm not sure, which url you are talking about. But one more thing I suspected that I'm registering to Marketing Cloud SDK and fetching Inbox Messages at the same time. Since registration is asynchronous, it might be possible getInboxMessages() get blocked till registration. – charlie Oct 20 '19 at 2:13
  • It is 100% blocked until registration is complete and, as I noted, you should be using requestSdk() as opposed to getInstance(). I assumed you already made that change. – Bill Mote Oct 21 '19 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.