Closed cherho0 closed 2 years ago
When draw anything will print this error
seems like you are adding a layer more than once. Don't do that and the error wont show up.
I have debug the source code when run to _setAll()
`Future
for (final annotation in _idToAnnotation.values) {
final layerIndex = selectLayer!(annotation);
_idToLayerIndex[annotation.id] = layerIndex;
featureBuckets[layerIndex].add(annotation);
}
for (var i = 0; i < featureBuckets.length; i++) {
await controller.setGeoJsonSource(
_makeLayerId(i),
buildFeatureCollection(
[for (final l in featureBuckets[i]) l.toGeoJson()]));
}
}`
the second value always null , then throw exception
I just draw a fill :
can you post the actual code causing this issue from your side? Also are on master?
I have the same exception triggered multiple times when I use this 2 line of code :
mapController?.setSymbolIconIgnorePlacement(true);
mapController?.setSymbolTextAllowOverlap(true);
To be more accurate, each line trigger 1 time the exception PlatformException(error, Layer 8tFZH1hObX_0 already exists, null, ...
We run this 2 lines in the onStyleLoadedCallback
function.
Exception stack trace :
W/Mbgl (22371): {GLThread 5093}[ParseStyle]: Layer '8tFZH1hObX_0' has an invalid value for text-font and will not render text. Output values must be contained as literals within the expression.
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): Failed to handle method call
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): com.mapbox.mapboxsdk.style.layers.CannotAddLayerException: Layer 8tFZH1hObX_0 already exists
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.mapbox.mapboxsdk.maps.NativeMapView.nativeAddLayer(Native Method)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.mapbox.mapboxsdk.maps.NativeMapView.addLayer(NativeMapView.java:858)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.mapbox.mapboxsdk.maps.Style.addLayer(Style.java:191)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.mapbox.mapboxgl.MapboxMapController.addSymbolLayer(MapboxMapController.java:370)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.mapbox.mapboxgl.MapboxMapController.onMethodCall(MapboxMapController.java:791)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java:206)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$R4HPk6oFVb-i-YR_PN9YE6kqx1I.run(Unknown Source:12)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at android.os.Looper.loop(Looper.java:246)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at android.app.ActivityThread.main(ActivityThread.java:8653)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): Failed to handle method call
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): com.mapbox.mapboxsdk.style.layers.CannotAddLayerException: Layer 8tFZH1hObX_0 already exists
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.mapbox.mapboxsdk.maps.NativeMapView.nativeAddLayer(Native Method)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.mapbox.mapboxsdk.maps.NativeMapView.addLayer(NativeMapView.java:858)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.mapbox.mapboxsdk.maps.Style.addLayer(Style.java:191)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.mapbox.mapboxgl.MapboxMapController.addSymbolLayer(MapboxMapController.java:370)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.mapbox.mapboxgl.MapboxMapController.onMethodCall(MapboxMapController.java:791)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java:206)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$R4HPk6oFVb-i-YR_PN9YE6kqx1I.run(Unknown Source:12)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at android.os.Looper.loop(Looper.java:246)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at android.app.ActivityThread.main(ActivityThread.java:8653)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
E/MethodChannel#plugins.flutter.io/mapbox_maps_0(22371): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
I/flutter (22371): ----------------FIREBASE CRASHLYTICS----------------
I/flutter (22371): PlatformException(error, Layer 8tFZH1hObX_0 already exists, null, com.mapbox.mapboxsdk.style.layers.CannotAddLayerException: Layer 8tFZH1hObX_0 already exists
I/flutter (22371): at com.mapbox.mapboxsdk.maps.NativeMapView.nativeAddLayer(Native Method)
I/flutter (22371): at com.mapbox.mapboxsdk.maps.NativeMapView.addLayer(NativeMapView.java:858)
I/flutter (22371): at com.mapbox.mapboxsdk.maps.Style.addLayer(Style.java:191)
I/flutter (22371): at com.mapbox.mapboxgl.MapboxMapController.addSymbolLayer(MapboxMapController.java:370)
I/flutter (22371): at com.mapbox.mapboxgl.MapboxMapController.onMethodCall(MapboxMapController.java:791)
I/flutter (22371): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
I/flutter (22371): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178)
I/flutter (22371): at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java:206)
I/flutter (22371): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$R4HPk6oFVb-i-YR_PN9YE6kqx1I.run(Unknown Source:12)
I/flutter (22371): at android.os.Handler.handleCallback(Handler.java:9
I/flutter (22371): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
I/flutter (22371): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
I/flutter (22371): <asynchronous suspension>
I/flutter (22371): #2 MethodChannelMapboxGl.addSymbolLayer (package:mapbox_gl_platform_interface/src/method_channel_mapbox_gl.dart:490:5)
I/flutter (22371): <asynchronous suspension>
I/flutter (22371): #3 MapboxMapController.addSymbolLayer (package:mapbox_gl/src/controller.dart:346:5)
I/flutter (22371): <asynchronous suspension>
I/flutter (22371): ----------------------------------------------------
I/flutter (22371): ----------------FIREBASE CRASHLYTICS----------------
I/flutter (22371): PlatformException(error, Layer 8tFZH1hObX_0 already exists, null, com.mapbox.mapboxsdk.style.layers.CannotAddLayerException: Layer 8tFZH1hObX_0 already exists
I/flutter (22371): at com.mapbox.mapboxsdk.maps.NativeMapView.nativeAddLayer(Native Method)
I/flutter (22371): at com.mapbox.mapboxsdk.maps.NativeMapView.addLayer(NativeMapView.java:858)
I/flutter (22371): at com.mapbox.mapboxsdk.maps.Style.addLayer(Style.java:191)
I/flutter (22371): at com.mapbox.mapboxgl.MapboxMapController.addSymbolLayer(MapboxMapController.java:370)
I/flutter (22371): at com.mapbox.mapboxgl.MapboxMapController.onMethodCall(MapboxMapController.java:791)
I/flutter (22371): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262)
I/flutter (22371): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:178)
I/flutter (22371): at io.flutter.embedding.engine.dart.DartMessenger.lambda$handleMessageFromDart$0$DartMessenger(DartMessenger.java:206)
I/flutter (22371): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$R4HPk6oFVb-i-YR_PN9YE6kqx1I.run(Unknown Source:12)
I/flutter (22371): at android.os.Handler.handleCallback(Handler.java:9
I/flutter (22371): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
I/flutter (22371): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
I/flutter (22371): <asynchronous suspension>
I/flutter (22371): #2 MethodChannelMapboxGl.addSymbolLayer (package:mapbox_gl_platform_interface/src/method_channel_mapbox_gl.dart:490:5)
I/flutter (22371): <asynchronous suspension>
I/flutter (22371): #3 MapboxMapController.addSymbolLayer (package:mapbox_gl/src/controller.dart:346:5)
I/flutter (22371): <asynchronous suspension>
I/flutter (22371): ----------------------------------------------------
Can you try adding an await to both statements?
@felix-ht Solution with await
is working in my case.
@cherho0 Maybe you are missing some await
too in others Mapbox function calls. I suppose that there is not these only 2 lines that can cause this exception.
I notice that instead of these exceptions we have this 2 lines now (1 for each call) :
W/Mbgl (21777): {GLThread 3589}[ParseStyle]: Layer 'xSll1DiN20_0' has an invalid value for text-font and will not render text. Output values must be contained as literals within the expression.
W/Mbgl (21777): {GLThread 3589}[ParseStyle]: Layer 'xSll1DiN20_0' has an invalid value for text-font and will not render text. Output values must be contained as literals within the expression.
We should probably add a function do an update to an existing layer as a single operation. With that there would no longer be a race condition.
I will take a look at the text font issue.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
We should probably add a function do an update to an existing layer as a single operation. With that there would no longer be a race condition.
I will take a look at the text font issue.
hey felix-ht, was this implemented already?
Any one found the cause of the text style issue ? I have the same thing happening
Unhandled Exception: PlatformException(error, Layer FD4ZSYlcHU_0 already exists, null, com.mapbox.mapboxsdk.style.layers.CannotAddLayerException: Layer FD4ZSYlcHU_0 already exists E/flutter ( 6263): at com.mapbox.mapboxsdk.maps.NativeMapView.nativeAddLayer(Native Method) E/flutter ( 6263): at com.mapbox.mapboxsdk.maps.NativeMapView.addLayer(NativeMapView.java:858) E/flutter ( 6263): at com.mapbox.mapboxsdk.maps.Style.addLayer(Style.java:191) E/flutter ( 6263): at com.mapbox.mapboxgl.MapboxMapController.addSymbolLayer(MapboxMapController.java:375) E/flutter ( 6263): at com.mapbox.mapboxgl.MapboxMapController.onMethodCall(MapboxMapController.java:740) E/flutter ( 6263): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:262) E/flutter ( 6263): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296) E/flutter ( 6263): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320) E/flutter ( 6263): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12) E/flutter ( 6263): at android.os.Handler.handleCallback(Handler.java:873) E/flutter ( 6263): at android.os.Handler.dispatchMessage(Handler.java:99) E/flutter ( 6263): at android.os.Looper.loop(Looper.java:193) E/flutter ( 6263): at android.app.ActivityThread.main(ActivityThread.java:6746) E/flutter ( 6263): at java.lang.reflect.Method.invoke(Native Method) E/flutter ( 6263): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) E/flutter ( 6263): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) E/flutter ( 6263): ) E/flutter ( 6263): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7) E/flutter ( 6263): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:177:18) E/flutter ( 6263):
E/flutter ( 6263): #2 MethodChannelMapboxGl.addSymbolLayer (package:mapbox_gl_platform_interface/src/method_channel_mapbox_gl.dart:483:5)
E/flutter ( 6263):
E/flutter ( 6263): #3 MapboxMapController.addSymbolLayer (package:mapbox_gl/src/controller.dart:352:5)
E/flutter ( 6263):
E/flutter ( 6263):