-
Notifications
You must be signed in to change notification settings - Fork 141
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
java.lang.Error: wstring_convert: to_bytes error #2121
Comments
Following #1054, I also just discovered this crash Pixel 6 Pro, Android 13 My code that can get called multiples times looks something like: map.getStyle()?.setStyleGeoJSONSourceData(sourceIdentifier, GeoJSONSourceData(feature))
val lastLayerInfo = map.getStyle()?.styleLayers?.lastOrNull()
val layer = map.getStyle()?.getLayer(circleLayerIdentifier)
if (
layer != null &&
lastLayerInfo != null &&
layer.layerId != lastLayerInfo.id
) {
map.getStyle()?.moveStyleLayer(circleLayerIdentifier, null)
} I can load the map just fine on the first app load, rendering features, annotations, and whatnot. I noticed when switching to and from the mapview screen few times, or even staying on the mapview screen and toggling state values (causing the screen to rerender), the app will crash. Commenting out the |
Still trying to figure this out, but I thought I should also probably mention I'm using jetpack compose, and my MapView is wrapped with an |
I'm starting to feel like this is on the mapbox native side rather than it being my code. I cannot run this project locally for the life of me in order to further debug due to errors with In the meantime this comment gave me the idea to ignore |
Ok so I managed to get the app building and running. I have a simple way to reproduce this error. In the compose-app module, replace your private fun MapboxMap() {
val mapView = mapView()
val mapIsReady = remember { mutableStateOf(false) }
var ticker by remember { mutableStateOf(0) }
fun ensureCircleSource(circleId: String, mapView: MapView) {
val map = mapView.getMapboxMap()
val sourceIdentifier = "source:${circleId}"
val source = map.getStyle()?.getSourceAs(sourceIdentifier) ?: GeoJsonSource.Builder(sourceIdentifier).build()
if (map.getStyle()?.styleSourceExists(sourceIdentifier) != true) {
source.data("")
map.getStyle()?.addSource(source)
}
}
fun drawCircle(mapView: MapView, id: String) {
val map = mapView.getMapboxMap()
val circleId = id
ensureCircleSource(circleId, mapView)
val sourceIdentifier = "source:${circleId}"
val circleLayerIdentifier = "layer:${circleId}"
val feature = Feature.fromGeometry(Point.fromLngLat(LONGITUDE, LATITUDE), null, "feature:${circleId}")
// Source should already be appended at this point, so update the geojson now
map.getStyle()?.setStyleGeoJSONSourceData(sourceIdentifier, GeoJSONSourceData(feature))
val lastLayerInfo = map.getStyle()?.styleLayers?.lastOrNull()
if (map.getStyle()?.styleLayerExists(circleLayerIdentifier) != true) {
val color = if (id == "circle1") "rgb(255, 0, 0)" else "rgb(0, 255, 0)"
val circleLayer = CircleLayer(circleLayerIdentifier, sourceIdentifier)
circleLayer.circleColor(color)
circleLayer.circleRadius(16.0)
map.getStyle()?.addLayer(circleLayer)
}
else {
val style = map.getStyle()!!
val layer = style.getLayer(circleLayerIdentifier)
if (
layer != null &&
lastLayerInfo != null &&
layer.layerId != lastLayerInfo.id
) {
// Move to top
if (style.styleLayerExists(layer.layerId)) {
style.moveStyleLayer(layer.layerId, null)
}
}
}
}
// Simulate view updates every second
LaunchedEffect(ticker) {
while (true) {
delay(4000)
ticker = 1 - ticker
}
}
AndroidView(
factory = {
val mapboxMap = mapView.getMapboxMap()
mapboxMap
.apply {
loadStyleUri(Style.MAPBOX_STREETS)
setCamera(
CameraOptions.Builder()
.center(Point.fromLngLat(LONGITUDE, LATITUDE))
.zoom(9.0)
.build()
)
}
var observer: Observer? = null
observer = Observer {
observer?.let {
mapboxMap.unsubscribeMapLoaded(it)
}
mapIsReady.value = true
}
mapboxMap.subscribeMapLoaded(observer)
mapView
},
modifier = Modifier.fillMaxSize()
) update@{ mapView ->
if (!mapIsReady.value) {
return@update
}
Log.d("Ticker", "update $ticker")
drawCircle(mapView, "circle1")
drawCircle(mapView, "circle2")
}
} |
Hey @NelsonBeard Maps SDK v9 is out dated and won't receive new fixes and please update to latest v10 stable releases for more bug fixes/improvements. Hey @okcoker have you tried our compose extension and see if you experience similar issues ? |
I have not, but will take a look and report back. Looking briefly at your link, it looks like I'll have to upgrade from v10 to v11 to try this out. Were you able to reproduce my issue above and fix it with the compose extension? |
Thanks!
No I haven't, will git it a try |
Closing as stale. The issue should be fixed in Compose extension for Maps v11. If not, please open the new issue. |
Environment
Observed behavior and steps to reproduce
Application crashes with next stacktrace:
java.lang.Error: wstring_convert: to_bytes error
at com.mapbox.mapboxsdk.maps.renderer.MapRendererRunnable.run(MapRendererRunnable.java)
at com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.guardedRun(MapboxGLSurfaceView.java:758)
at com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.MapboxGLSurfaceView$GLThread.run(MapboxGLSurfaceView.java:568)
Expected behavior
No application crash
Notes / preliminary analysis
Hi! Many users of our app got this crash. I can't reproduce it by my own. App crashes whenever it wants - on startup, on map clicks, after block/unblock screen, etc. All this information (and stacktrace) i get via Sentry (issue monitoring tool)
Can you help me with this crash, please?
P.S. Maybe update Maps SDK Version to newest can solve this problem?
Additional links and references
Most similar issue was #1054 (comment), but i don't see solution there
The text was updated successfully, but these errors were encountered: