Open rakshitsoni02 opened 2 years ago
@rakshitsoni02 could you test if it also happens with version 2.7.0?
Hi @rakshitsoni02 @polivmi1 , I am facing the same issue and it also happens with upgraded version, is there any fix/workaround for this issue?
hey @minaxiDH unfortunately no solid workaround I tried to dispose compose view in onstop() but still randomly failing the test suite
@minaxiDH @rakshitsoni02 Would you be able to provide a sample project with a test that causes this crash? Our project has instrumentation tests that don't have this issue, so there may be something different in your setup that we can investigate.
Reopening for comments from developers reporting this issue in the Maps SDK for Android issue tracker.
Experiencing the same issue when writing an automation test - crashing due to the following issue: com.google.maps.api.android.lib6.common.apiexception.c: Not on the main thread
Has anyone found any workarounds?
It doesn't throw if you change the rule from being createAndroidComposeRule<ComponentActivity>()
to createAndroidComposeRule<MainActivity>()
.
Here's a project that reproduces the issue https://github.com/amrfarid140/googlemapscompose-issue-reporducer. It has 2 tests.
TestWithIssue
throws the error. It uses createAndroidComposeRule<ComponentActivity>()
then navigates to MainActivity
where GoogleMap composable is createdTestWithoutIssue
doesn't throw the error. It uses createAndroidComposeRule<Main>()
to launch MainActivity
where GoogleMap composable is created.To run the sample project you will need to replace Google Maps API key in the AndroidManifest. The key in there is not valid anymore.
Not sure if anyone is looking into this yet but something interesting I found was when the test fails.
The call to disposingComposition changes threads at the point of calling composition.dispose()
. See screenshots.
Phase | Screenshot |
---|---|
calling factory() |
|
calling awaitCancellation |
|
Disposing composition |
When we launch a Google Map containing activity, the cancellation signal comes from a LifecycleObserver inside WrappedComposition
which runs on the main thread.
When we launch an activity then navigate to a GoogleMap containing activity , the cancellation signal comes from AndroidComposeUiTestEnvironment
which runs on the test thread.
Still don't know why this is happening.
I'm facing the same issue as well. Any update on this issue?
The workaround I have so far is to finish the activity/activities as part of the test instead of waiting for the test to tear down.
I'm using ActivityScenario to launch activities in test. I have this same issue when the Google Map containing activity is launched from another one.
Closing the activity with Espresso.pressBackUnconditionally()
works for me.
@amrfarid140 @Ayskin thank you so much. Finally, it works.
This doesn't work if we need to assert on map screen, has anyone found any workaround on it?
@minaxiDH Any workaround for this issue?
@shriharsha-bhagwat this is still an open issue, we can't assert anything on map screen with composeView as it crashes with same exception, but it can be successfully closed using Espresso.pressBackUnconditionally()
Please comment here if you're still seeing this issue with v3.1.0.
started experiencing this issue with the same stacktrace as above with one of the instrumentation test that launches an Activity after updating the androidx.navigation library from 2.7.4 to the latest 2.7.5, is there a known conflict between the latest version of maps-compose and androidx.navigation?
Facing the same issue. Using last version.
Fix: Injecting the main dispatcher fixes the crash.
@get:Rule val composeTestRule = createComposeRule(
effectContext = EmptyCoroutineContext + Dispatchers.Main.immediate
)
(EmptyCoroutineContext is not necessary)
We're still seeing this on version 4.3.3 of the lib. Closing the app using pressBackUnconditionally()
doesn't work reliably enough, and overriding the effectContext
fails for other reasons.
Issue still there on version 6.1.2 of the lib. Adding effectContext crashes with java.lang.IllegalStateException: Method removeObserver must be called on the main thread
this issue prevent to update the androidx_navigation from 2.7.4 to 2.8.1 and workarounds are not working in our case. is there any estimation when it would be fixed?
Issue reproduced on v6.1.2 as well.
I managed to avoid it using launchActivity<StoresActivity>().use {}
but it's really not ideal.
Still happening, no workarounds working for us, any clue?
Device: Pixel 5 API 30 sdk version: 2.5.3 & 2.7.2
i've implemented GoogleMap with ComposeView, it's crashing in the instrumentation test case with the following stack trace:
ComposeView:
component:
I've tried running the test on the UI thread but no luck it seems like an issue when disposing of the mapview. The implementation used from the activity also tried setting different disposition strategy.