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

Google Map Compose laggy Skipped 32 frames! The application may be doing too much work on its main thread. #664

Open
vanniktech opened this issue Dec 13, 2024 · 1 comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@vanniktech
Copy link

vanniktech commented Dec 13, 2024

I'm using GoogleMaps as follows:

Box {
	val mapUiSettings by remember {
	  mutableStateOf(
	    MapUiSettings(
	      mapToolbarEnabled = false,
	      myLocationButtonEnabled = false, // We don't want that button.
	      zoomControlsEnabled = false,
	    ),
	  )
	}
	
	val cameraPositionState = rememberCameraPositionState()
	
	GoogleMap(
	  properties = MapProperties(isMyLocationEnabled = isMyLocationEnabled),
	  modifier = modifier,
	  cameraPositionState = cameraPositionState,
	  uiSettings = mapUiSettings,
	  mapColorScheme = ComposeMapColorScheme.FOLLOW_SYSTEM,
	)
	
  ScaleBar(
    modifier = Modifier
      .padding(top = 5.dp, end = 15.dp)
      .align(Alignment.TopEnd),
    cameraPositionState = cameraPositionState,
    textColor = MaterialTheme.colorScheme.onBackground,
    lineColor = MaterialTheme.colorScheme.onBackground,
    shadowColor = Color.Transparent,
  )

}

The problem is that there seems to be going to much going on since in Logcat I can see:

Skipped 32 frames! The application may be doing too much work on its main thread.

Now this is just a super simple map that is displayed with the following Modifier: Modifier.fillMaxWidth().aspectRatio(1f)

Is there any trick to speed it up or am I doing something wrong? I'm already on the last 6.4.0 version.

@vanniktech vanniktech 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 Dec 13, 2024
@vanniktech
Copy link
Author

What did help a bit was putting the GoogleMap inside a LazyColumn but now the initial loading takes super long which isn't nice either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. 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

1 participant