[go: nahoru, domu]

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

StrictMode detectDiskReads() causes Google Maps to be extremely laggy and ANRs #159

Open
mkpazon opened this issue Jun 29, 2022 · 3 comments
Assignees
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@mkpazon
Copy link
mkpazon commented Jun 29, 2022

Thanks for stopping by to let us know something could be better!


PLEASE READ

If you have a support contract with Google, please create an issue in the support console. This will ensure a timely response.

Discover additional support services for the Google Maps Platform, including developer communities, technical guidance, and expert support at the Google Maps Platform support resources page.

If your bug or feature request is not related to this particular library, please visit the Google Maps Platform issue trackers.

Check for answers on StackOverflow with the google-maps tag.


Please be sure to include as much information as possible:

Environment details

Library version: Tested with Maps Compose 1.2.0 and 2.2.1

Steps to reproduce

  1. Enable detect disk reads in StrictMode (see code example)

Code example

StrictMode.setThreadPolicy(
    ThreadPolicy.Builder()
        .detectDiskReads()
        .build()
)
@mkpazon mkpazon added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jun 29, 2022
@hlandim
Copy link
hlandim commented May 19, 2023

I'm getting this log when using StrictMode:

StrictMode policy violation: android.os.strictmode.IncorrectContextUseViolation: The API:ViewConfiguration needs a proper configuration. Use UI contexts such as an activity or a context created via createWindowContext(Display, int, Bundle) or  createConfigurationContext(Configuration) with a proper configuration.
                                                                                        	at android.os.StrictMode.onIncorrectContextUsed(StrictMode.java:2261)
                                                                                        	at android.os.StrictMode.assertConfigurationContext(StrictMode.java:2297)
                                                                                        	at android.view.ViewConfiguration.get(ViewConfiguration.java:522)
                                                                                        	at android.view.View.<init>(View.java:5330)
                                                                                        	at android.view.TextureView.<init>(TextureView.java:146)
                                                                                        	at com.google.maps.api.android.lib6.gmm6.vector.av.<init>(:com.google.android.gms.dynamite_mapsdynamite@231613044@23.16.13 (190400-0):1)
                                                                                        	at com.google.maps.api.android.lib6.gmm6.vector.ac.<init>(:com.google.android.gms.dynamite_mapsdynamite@231613044@23.16.13 (190400-0):1)
                                                                                        	at com.google.maps.api.android.lib6.gmm6.api.ac.<init>(:com.google.android.gms.dynamite_mapsdynamite@231613044@23.16.13 (190400-0):1)
                                                                                        	at com.google.maps.api.android.lib6.impl.bk.aD(:com.google.android.gms.dynamite_mapsdynamite@231613044@23.16.13 (190400-0):54)
                                                                                        	at com.google.maps.api.android.lib6.impl.cu.d(:com.google.android.gms.dynamite_mapsdynamite@231613044@23.16.13 (190400-0):2)
                                                                                        	at com.google.android.gms.maps.internal.q.bb(:com.google.android.gms.dynamite_mapsdynamite@231613044@23.16.13 (190400-0):21)

This is my code.

GoogleMap(
        modifier = Modifier
            .fillMaxSize()
            .background(color = Color.Gray),
        cameraPositionState = cameraPositionState,
        contentPadding = paddings,
        uiSettings = mapSettings,
    ) {
        latLng?.let {
            VehicleMarker(it, onSetupEvent)
            MapEffect(latLng) {
                cameraPositionState.animate(
                    CameraUpdateFactory.newLatLngZoom(latLng, 16f),
                )
            }
        }
    }

@kikoso kikoso added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed triage me I really want to be triaged. labels Jul 10, 2023
@ulfandersson
Copy link

I see the same issue with maps-compose 3.1.1.

My current workaround where GoogleMaps composable is used:

  if (strictModeEnabled) {
       DisposableEffect(Unit) {
           val prevThreadPolicy = StrictMode.allowThreadDiskReads()
           onDispose {
               StrictMode.setThreadPolicy(prevThreadPolicy)
           }
       }
   }

@bubenheimer
Copy link
Contributor

@hlandim your StrictMode problem looks very different from what this issue is about. Consider creating a new issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

6 participants