-
Notifications
You must be signed in to change notification settings - Fork 25
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
Note that observation on multiple threads in layout/draw is not supported. Make sure your measure/layout/draw for each Owner (AndroidComposeView) is executed on the same thread #203
Comments
Hello @xemniz thanks for the issue. |
right here they discuss that you should call |
@xemniz |
@xemniz what's the version of your resolved |
androidx.compose:compose-bom:2024.10.00 - compose version |
yes, but having crash not in PostHogSdk code, but in |
Session replay tries to do as much as possible off of the main thread because of performance reasons, so the replay thread calls that function.
So only that part will be accessed via the main thread, unless |
@beradeep did you see this one, any ideas? |
@marandaneto I looked into it just a bit, turns out I was able to reproduce the issue. But its occurrence is unpredictable. It came up a couple of times when I ran a sample app repeatedly for at least 10 times. |
Thanks, can you share the sample app you tried? So I can try to reproduce it myself as well. Any help here is appreciated since I cannot reproduce the issue at all. |
@marandaneto I faced the issue in the app startup, so I think it is practically possible with any compose app, although I only tried with The google issuetracker comment also mentions that they always call |
But as this comment mentions, the properties that we use i.e. |
So in this case the whole block should be executed in the main thread. |
https://github.com/PostHog/posthog-android/releases/tag/3.9.1 |
The entire logic such as getAllSemanticsNodes is put into the main thread for execution. Have you ever encountered a situation where the execution is very slow and the main thread is stuck? I tested that getting SemanticsNodes in the main thread would cause a hang. |
Version
3.9.0
Steps to Reproduce
Expected Result
App works
Actual Result
java.lang.IllegalArgumentException: Detected multithreaded access to : previousThreadId=158), currentThread={id=2, name=main}. Note that observation on multiple threads in layout/draw is not supported. Make sure your measure/layout/draw for each Owner (AndroidComposeView) is executed on the same thread.
at androidx.compose.runtime.PreconditionsKt.throwIllegalArgumentException(Preconditions.kt:26)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:708)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113)
The text was updated successfully, but these errors were encountered: