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

Android: session replay causes crashes #10

Open
jrusso1020 opened this issue Oct 24, 2024 · 4 comments
Open

Android: session replay causes crashes #10

jrusso1020 opened this issue Oct 24, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@jrusso1020
Copy link

We are getting the following error on react-native 0.74.5 and "expo": "~51.0.38" and the latest versions of posthog and session-replay plugin

"posthog-react-native": "^3.3.6",
"posthog-react-native-session-replay": "^0.1.5",

Our configuration is like so

posthogInstance = new PostHog(config.posthog.apiKey, {
   host: 'https://us.i.posthog.com',
   disableGeoip: true,
   // Comment out the line below to enable PostHog in dev
   disabled: __DEV__ || !config.posthog.enabled, // Disable in dev or if not enabled in config
   enableSessionReplay: true,
 });

This error occurs so much that it will eventually crash the app. Disabling session replay explicitly we avoid this issue. I also thought that enableSessionReplay would only be enabled when posthog itself was enabled, but it seems like that may not be the case?

Unhandled SoftException
                                                                                                    com.facebook.react.bridge.AssertionException: Expected to run on UI thread!
                                                                                                    	at com.facebook.react.bridge.SoftAssertions.assertCondition(SoftAssertions.java:37)
                                                                                                    	at com.facebook.react.bridge.UiThreadUtil.assertOnUiThread(UiThreadUtil.java:44)
                                                                                                    	at com.facebook.react.views.view.ReactViewGroup.getChildDrawingOrder(ReactViewGroup.java:585)
                                                                                                    	at android.view.View.populateAccessibilityNodeInfoDrawingOrderInParent(View.java:11530)
                                                                                                    	at android.view.View.onInitializeAccessibilityNodeInfoInternal(View.java:11445)
                                                                                                    	at android.view.ViewGroup.onInitializeAccessibilityNodeInfoInternal(ViewGroup.java:3792)
                                                                                                    	at android.view.View.onInitializeAccessibilityNodeInfo(View.java:9347)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.isVisible(PostHogReplayIntegration.kt:468)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:560)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.findMaskableWidgets(PostHogReplayIntegration.kt:564)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.toScreenshotWireframe(PostHogReplayIntegration.kt:588)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.generateSnapshot(PostHogReplayIntegration.kt:354)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration.access$generateSnapshot(PostHogReplayIntegration.kt:90)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration$addView$1$2$listener$1.invoke$lambda$0(PostHogReplayIntegration.kt:151)
                                                                                                    	at com.posthog.android.replay.PostHogReplayIntegration$addView$1$2$listener$1.$r8$lambda$-IwNlQE4yL80dvYYnw2AtjgKjhQ(Unknown Source:0)
2024-10-24 11:01:57.098  6427-6541  unknown:SoftAssertions  com.empiricalhealth.EmpiricalHealth  E  	at com.posthog.android.replay.PostHogReplayIntegration$addView$1$2$listener$1$$ExternalSyntheticLambda0.run(Unknown Source:8)
                                                                                                    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487)
                                                                                                    	at java.util.concurrent.FutureTask.run(FutureTask.java:264)
                                                                                                    	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)

These errors trigger the following error

java.lang.OutOfMemoryError: Failed to allocate a 32 byte allocation with 1037024 free bytes and 1012KB until OOM, target footprint 201326592, growth limit 201326592; giving up on allocation because <1% of heap free after GC.
                                                                                                    	at java.util.ArrayList.iterator(ArrayList.java:1036)
                                                                                                    	at com.facebook.yoga.YogaNodeJNIBase.calculateLayout(YogaNodeJNIBase.java:207)
                                                                                                    	at com.facebook.react.uimanager.ReactShadowNodeImpl.calculateLayout(ReactShadowNodeImpl.java:485)
                                                                                                    	at com.facebook.react.uimanager.UIImplementation.calculateRootLayout(UIImplementation.java:936)
                                                                                                    	at com.facebook.react.uimanager.UIImplementation.updateViewHierarchy(UIImplementation.java:637)
                                                                                                    	at com.facebook.react.uimanager.UIImplementation.dispatchViewUpdates(UIImplementation.java:598)
                                                                                                    	at com.facebook.react.uimanager.UIManagerModule.onBatchComplete(UIManagerModule.java:714)
                                                                                                    	at com.facebook.react.uimanager.ReanimatedUIManager.onBatchComplete(ReanimatedUIManager.java:25)
                                                                                                    	at com.facebook.react.bridge.NativeModuleRegistry.onBatchComplete(NativeModuleRegistry.java:118)
                                                                                                    	at com.facebook.react.bridge.CatalystInstanceImpl$InstanceCallback.lambda$onBatchComplete$0(CatalystInstanceImpl.java:172)
                                                                                                    	at com.facebook.react.bridge.CatalystInstanceImpl$InstanceCallback$$ExternalSyntheticLambda0.run(Unknown Source:2)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:959)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:100)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:232)
                                                                                                    	at android.os.Looper.loop(Looper.java:317)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:233)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
@ioannisj
Copy link

Hey @jrusso1020! Any chance you are instantiating PostHog in a background thread? Pure speculation here, but if that's the case try switching to ui thread first.

@marandaneto
Copy link
Member

@jrusso1020 for the disabled flag, that was an oversight, thanks for catching this, PR here.
For the "Expected to run on UI thread" bits, I will look into it next week since I am on PTO tomorrow, but what @ioannisj said here might be a good start, but most likely you don't have control over this since the JS bridge in RN runs on a background thread anyway.

@marandaneto
Copy link
Member

@jrusso1020 I could not reproduce the issue but maybe PostHog/posthog-android#201 and #11 should help, we will get it merged/released and will let you know, it'd be awesome if you can give it a try (watch console logs btw), thanks.

@marandaneto
Copy link
Member

marandaneto commented Oct 25, 2024

@jrusso1020 can you try to upgrade the replay plugin to https://github.com/PostHog/posthog-react-native-session-replay/releases/tag/0.1.6 and the SDK to https://github.com/PostHog/posthog-js-lite/releases/tag/posthog-react-native-v3.3.7 and let us know? thanks.
edit: sorry pending this release PostHog/posthog-js-lite#299 (v3.3.9)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants