Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: ANRs coming from com.onesignal.common.modeling.Model.initializeFromJson #2236

Open
1 task done
isles1217 opened this issue Dec 24, 2024 · 2 comments
Open
1 task done
Labels
WIP Work In Progress

Comments

@isles1217
Copy link

isles1217 commented Dec 24, 2024

What happened?

This is a follow up issue to #2230. A bulk of our ANRs have been fixed following the release of 5.1.26, but I'm still seeing ANRs with one particular stack trace. We really appreciate the work on reducing these ANRs, and I'm hoping this particular trace gets rid of the last major culprit. Thanks for the improvements so far!

Steps to reproduce?

See stack trace / log output

What did you expect to happen?

OneSignal to not block the main thread

OneSignal Android SDK version

5.1.26

Android version

13, 12, 11

Specific Android models

Any

Relevant log output

com.onesignal.common.modeling.Model.initializeFromJson
ANR triggered by slow operations in blamed thread

OpRepo (runnable):
          OpRepo (runnable):tid=57 systid=18118 
#00 pc 0x4a7ee8 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 0x5b59dc libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool, BacktraceMap*, bool) const + 376)
#02 pc 0x5d2b14 libart.so (art::DumpCheckpoint::Run(art::Thread*) + 924)
#03 pc 0x5b6910 libart.so (art::Thread::RunCheckpointFunction() + 176)
#04 pc 0x6739fc libart.so (art::JniMethodFastEndWithReference(_jobject*, unsigned int, art::Thread*) + 112)
       at java.lang.reflect.Executable.getMethodNameInternal(Native method)
       at java.lang.reflect.Method.getName(Method.java:115)
       at java.lang.reflect.Method$1.compare(Method.java:72)
       at java.lang.reflect.Method$1.compare(Method.java:67)
       at libcore.util.CollectionUtils.removeDuplicates(CollectionUtils.java:89)
       at java.lang.Class.getMethods(Class.java:1493)
       at com.onesignal.common.modeling.Model.initializeFromJson(Model.kt)
       at com.onesignal.core.internal.operations.impl.OperationModelStore.create(OperationModelStore.kt:67)
       at com.onesignal.core.internal.operations.impl.OperationModelStore.create(OperationModelStore.kt:30)
       at com.onesignal.common.modeling.ModelStore.load(ModelStore.kt)
       at com.onesignal.core.internal.operations.impl.OperationModelStore.loadOperations(OperationModelStore.kt)
       at com.onesignal.core.internal.operations.impl.OperationRepo.loadSavedOperations$com_onesignal_core(OperationRepo.kt)
       at com.onesignal.core.internal.operations.impl.OperationRepo$start$1.invokeSuspend(OperationRepo.kt)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:923)

main (blocked)
tid=1 systid=18010 | waiting to lock <0x059286bb> (java.util.ArrayList) held by thread 57
          main (blocked):tid=1 systid=18010 | waiting to lock <0x059286bb> (java.util.ArrayList) held by thread 57
       at com.onesignal.common.modeling.ModelStore.add(ModelStore.kt:45)
       at com.onesignal.common.modeling.IModelStore$DefaultImpls.add$default(IModelStore.kt:36)
       at com.onesignal.core.internal.operations.impl.OperationRepo.internalEnqueue(OperationRepo.kt)
       at com.onesignal.core.internal.operations.impl.OperationRepo.internalEnqueue$default(OperationRepo.kt)
       at com.onesignal.core.internal.operations.impl.OperationRepo.enqueue(OperationRepo.kt)
       at com.onesignal.session.internal.session.impl.SessionListener.onSessionStarted(SessionListener.kt)
       at com.onesignal.session.internal.session.impl.SessionService$onFocus$1.invoke(SessionService.kt:107)
       at com.onesignal.session.internal.session.impl.SessionService$onFocus$1.invoke(SessionService.kt:107)
       at com.onesignal.common.events.EventProducer.fire(EventProducer.kt)
       at com.onesignal.session.internal.session.impl.SessionService.onFocus(SessionService.kt)
       at com.onesignal.core.internal.application.impl.ApplicationService$handleFocus$1.invoke(ApplicationService.kt:395)
       at com.onesignal.core.internal.application.impl.ApplicationService$handleFocus$1.invoke(ApplicationService.kt:395)
       at com.onesignal.common.events.EventProducer.fire(EventProducer.kt)
       at com.onesignal.core.internal.application.impl.ApplicationService.handleFocus(ApplicationService.kt)
       at com.onesignal.core.internal.application.impl.ApplicationService.onActivityStarted(ApplicationService.kt)
       at android.app.Application.dispatchActivityStarted(Application.java:425)
       at android.app.Activity.dispatchActivityStarted(Activity.java:1382)
       at android.app.Activity.onStart(Activity.java:1873)
       at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1435)
       at android.app.Activity.performStart(Activity.java:8231)
       at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3872)
       at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
       at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2336)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8653)
       at java.lang.reflect.Method.invoke(Native method)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jinliu9508
Copy link
Contributor

@isles1217 Great to hear that bulks of ANRs have been resolved in our latest release! We are currently investigating this particular stack trace and will provide an update once a new release is available.

@jinliu9508 jinliu9508 added the WIP Work In Progress label Jan 7, 2025
@jinliu9508
Copy link
Contributor

jinliu9508 commented Jan 10, 2025

@isles1217 The stack trace indicates that the operation is enqueuing and waiting on the main thread. However, the 5.1.26 release has moved this step to the background thread. Could you double-check that this isn't happening in your latest version? Additionally, could you provide another stack trace that includes line numbers for these lines of code?

main (blocked)
tid=1 systid=18010 | waiting to lock <0x059286bb> (java.util.ArrayList) held by thread 57
          main (blocked):tid=1 systid=18010 | waiting to lock <0x059286bb> (java.util.ArrayList) held by thread 57
       at com.onesignal.common.modeling.ModelStore.add(ModelStore.kt:45)
       at com.onesignal.common.modeling.IModelStore$DefaultImpls.add$default(IModelStore.kt:36)
       at com.onesignal.core.internal.operations.impl.OperationRepo.internalEnqueue(OperationRepo.kt)
       at com.onesignal.core.internal.operations.impl.OperationRepo.internalEnqueue$default(OperationRepo.kt)
       at com.onesignal.core.internal.operations.impl.OperationRepo.enqueue(OperationRepo.kt)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work In Progress
Projects
None yet
Development

No branches or pull requests

2 participants