Closed wangjingyang closed 5 months ago
@wangjingyang which version of the SDK are you using? is it crashing the app or just logging on to Logcat?
v3.2.2 Yes, it crashed and was reported to firebase。 I think the code should be like this:
private fun cleanSessionState(
view: View,
status: ViewTreeSnapshotStatus,
) {
view.viewTreeObserver?.let { viewTreeObserver ->
mainHandler.handler.post {
if (viewTreeObserver.isAlive) { // Move this line of code inside the post code block
viewTreeObserver.removeOnDrawListener(status.listener)
}
}
}
view.phoneWindow?.let { window ->
window.touchEventInterceptors -= onTouchEventListener
}
decorViews.remove(view)
}
@wangjingyang I have a draft PR already https://github.com/PostHog/posthog-android/pull/134/files
Thanks for reporting it, sorry about that.
Not sure if it crashed tho, Since cleanSessionState
is called by uninstall
and the uninstall
already swallows exceptions.
Same for onRootViewsChangedListener
.
Maybe it'd crash because when we do mainHandler.handler.post
, it's in a different scope so I have added another try catch anyway.
When will the new version be updated?
Once https://github.com/PostHog/posthog-android/actions/runs/9219736666 finishes running it'll be published, usually maven central has a few minutes delay as well
Description
Exception java.lang.IllegalStateException: This ViewTreeObserver is not alive, call getViewTreeObserver() again at android.view.ViewTreeObserver.checkIsAlive (ViewTreeObserver.java:984) at android.view.ViewTreeObserver.removeOnDrawListener (ViewTreeObserver.java:759) at com.posthog.android.replay.PostHogReplayIntegration.cleanSessionState$lambda$6$lambda$5 (PostHogReplayIntegration.kt:253) at com.posthog.android.replay.PostHogReplayIntegration.$r8$lambda$Fo0KroR9KoezO0ojDFIMQW4ICps at com.posthog.android.replay.PostHogReplayIntegration$$ExternalSyntheticLambda2.run at android.os.Handler.handleCallback (Handler.java:938) at android.os.Handler.dispatchMessage (Handler.java:99) at android.os.Looper.loopOnce (Looper.java:226) at android.os.Looper.loop (Looper.java:313) at android.app.ActivityThread.main (ActivityThread.java:8663) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135)