-
Notifications
You must be signed in to change notification settings - Fork 175
Open
Labels
priority: p0Highest priority. Critical issue. P0 implies highest priority.Highest priority. Critical issue. P0 implies highest priority.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
I'm new to Android SDK, so maybe i'm making a rookie mistake.
This is my composable:
@Composable
private fun Overlays(startX: Int, endX: Int, startY: Int, endY: Int, cellSize: Int) {
Log.d("GRID", "$startX, $startY - $endX, $endY ($cellSize)")
for (x in startX..endX) {
for (y in startY..endY) {
var northEast = LatLng(yToLat(y + 1, cellSize), xTolng(x + 1, cellSize))
var southWest = LatLng(yToLat(y, cellSize), xTolng(x, cellSize))
Log.d(
"GRID",
"draw ${southWest.latitude} to ${northEast.latitude} EN ${southWest.longitude} toi ${northEast.longitude}"
)
val p = GroundOverlayPosition.create(LatLngBounds(southWest, northEast))
Log.d("GRID", "get rect")
val rect = getrect()
Log.d("GRID", "do overlay")
GroundOverlay(position = p, image = rect)
Log.d("GRID", "overlay don")
;
}
}
Log.d("GRID", "return")
}
getrect is just a simple temporary test thing:
fun getrect(): BitmapDescriptor {
val borderPaint = Paint(Paint.ANTI_ALIAS_FLAG)
borderPaint.style = Paint.Style.STROKE
borderPaint.alpha = 128
borderPaint.strokeWidth = 10f
borderPaint.color = Color.RED
var bitmapborder = Bitmap.createBitmap(
(512).toInt(),
(512).toInt(), Bitmap.Config.ARGB_8888
)
val canvas = Canvas(bitmapborder)
canvas.drawRect(
0f, 0f, 512f, 512f,
borderPaint
)
borderPaint.color = Color.GREEN
canvas.drawLine(20f, 20f, 490f, 490f, borderPaint)
var o = GroundOverlayOptions()
var bitmap = BitmapDescriptorFactory.fromBitmap(bitmapborder)
bitmapborder.recycle()
return bitmap
}Using it in a GoogleMap like this:
GoogleMap(
properties = MapProperties(isMyLocationEnabled = true),
cameraPositionState = p
)
{
val visibleRegion = p.projection?.visibleRegion
if (visibleRegion != null) {
val level = gridLevels - p.position.zoom.toInt() + 5
// Log.d("GRID", "level =$level")
val cellSize = getCellSize(level)
val startX = lngToX(visibleRegion.farLeft.longitude, cellSize)
val endX = lngToX(visibleRegion.farRight.longitude, cellSize)
val endY = latToY(visibleRegion.farLeft.latitude, cellSize)
val startY = latToY(visibleRegion.nearRight.latitude, cellSize)
Overlays(startX, endX, startY, endY, cellSize)
}
}This works perfectly, but after moving the map a while, the app suddenly freezes. Sometimes pretty quickly, sometimes it takes like 10-20 seconds.
This is the last log output:
2023-08-16 14:02:27.431 17740-17740 GRID com...ng.backgroundlocationtracking D 350, -75 - 351, -72 (20480)
2023-08-16 14:02:27.431 17740-17740 GRID com...ng.backgroundlocationtracking D draw -13.820531046707277 to -13.636257299417846 EN 104.75856316522831 toi 105.05787334570039
2023-08-16 14:02:27.431 17740-17740 GRID com...ng.backgroundlocationtracking D get rect
2023-08-16 14:02:27.433 17740-17740 GRID com...ng.backgroundlocationtracking D do overlay
2023-08-16 14:02:27.433 17740-17740 GRID com...ng.backgroundlocationtracking D overlay don
2023-08-16 14:02:27.433 17740-17740 GRID com...ng.backgroundlocationtracking D draw -13.636257299417846 to -13.451983552128416 EN 104.75856316522831 toi 105.05787334570039
2023-08-16 14:02:27.433 17740-17740 GRID com...ng.backgroundlocationtracking D get rect
2023-08-16 14:02:27.435 17740-17803 Counters com...ng.backgroundlocationtracking I exceeded sample count in FrameTime
2023-08-16 14:02:27.435 17740-17740 GRID com...ng.backgroundlocationtracking D do overlay
2023-08-16 14:02:27.436 17740-17740 GRID com...ng.backgroundlocationtracking D overlay don
2023-08-16 14:02:27.436 17740-17740 GRID com...ng.backgroundlocationtracking D draw -13.451983552128416 to -13.267709804838987 EN 104.75856316522831 toi 105.05787334570039
2023-08-16 14:02:27.436 17740-17740 GRID com...ng.backgroundlocationtracking D get rect
2023-08-16 14:02:27.437 17740-17740 GRID com...ng.backgroundlocationtracking D do overlay
2023-08-16 14:02:27.437 17740-17740 GRID com...ng.backgroundlocationtracking D overlay don
2023-08-16 14:02:27.437 17740-17740 GRID com...ng.backgroundlocationtracking D draw -13.267709804838987 to -13.083436057549555 EN 104.75856316522831 toi 105.05787334570039
2023-08-16 14:02:27.437 17740-17740 GRID com...ng.backgroundlocationtracking D get rect
2023-08-16 14:02:27.438 17740-17740 GRID com...ng.backgroundlocationtracking D do overlay
2023-08-16 14:02:27.439 17740-17740 GRID com...ng.backgroundlocationtracking D overlay don
2023-08-16 14:02:27.439 17740-17740 GRID com...ng.backgroundlocationtracking D draw -13.820531046707277 to -13.636257299417846 EN 105.05787334570039 toi 105.35718352617246
2023-08-16 14:02:27.439 17740-17740 GRID com...ng.backgroundlocationtracking D get rect
2023-08-16 14:02:27.440 17740-17740 GRID com...ng.backgroundlocationtracking D do overlay
2023-08-16 14:02:27.440 17740-17740 GRID com...ng.backgroundlocationtracking D overlay don
2023-08-16 14:02:27.440 17740-17740 GRID com...ng.backgroundlocationtracking D draw -13.636257299417846 to -13.451983552128416 EN 105.05787334570039 toi 105.35718352617246
2023-08-16 14:02:27.440 17740-17740 GRID com...ng.backgroundlocationtracking D get rect
2023-08-16 14:02:27.441 17740-17740 GRID com...ng.backgroundlocationtracking D do overlay
2023-08-16 14:02:27.441 17740-17740 GRID com...ng.backgroundlocationtracking D overlay don
2023-08-16 14:02:27.441 17740-17740 GRID com...ng.backgroundlocationtracking D draw -13.451983552128416 to -13.267709804838987 EN 105.05787334570039 toi 105.35718352617246
2023-08-16 14:02:27.441 17740-17740 GRID com...ng.backgroundlocationtracking D get rect
2023-08-16 14:02:27.443 17740-17740 GRID com...ng.backgroundlocationtracking D do overlay
2023-08-16 14:02:27.443 17740-17740 GRID com...ng.backgroundlocationtracking D overlay don
2023-08-16 14:02:27.443 17740-17740 GRID com...ng.backgroundlocationtracking D draw -13.267709804838987 to -13.083436057549555 EN 105.05787334570039 toi 105.35718352617246
2023-08-16 14:02:27.443 17740-17740 GRID com...ng.backgroundlocationtracking D get rect
2023-08-16 14:02:27.444 17740-17740 GRID com...ng.backgroundlocationtracking D do overlay
2023-08-16 14:02:27.444 17740-17740 GRID com...ng.backgroundlocationtracking D overlay don
2023-08-16 14:02:27.444 17740-17740 GRID com...ng.backgroundlocationtracking D return
After that last return the app hangs and i get the 'app isnt responding' popup.
Tried to update everything to the latest versions to no avail:
plugins {
id 'com.android.application' version '8.1.0' apply false
// id 'com.android.application' version '8.1.0' apply false
id 'com.android.library' version '8.1.0' apply false
id 'org.jetbrains.kotlin.android' version '1.9.0' apply false
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
}
android {
compileSdk 34
defaultConfig {
applicationId "com.plcoding.backgroundlocationtracking"
minSdk 31
//targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
......
dependencies {
implementation 'androidx.core:core-ktx:1.10.1'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.2'
// implementation 'org.osmdroid:osmdroid-android:6.1.16'
implementation 'com.google.maps.android:maps-compose:2.13.0'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'androidx.sqlite:sqlite:2.3.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
// Location Services
implementation 'com.google.android.gms:play-services-location:21.0.1'
}
Am i using it wrong, or am i triggering some unkown bug due to the intensity of adding/removing groundoverlays?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority: p0Highest priority. Critical issue. P0 implies highest priority.Highest priority. Critical issue. P0 implies highest priority.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.