Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

[MapSnapshotter] withLayers/withLayerBelow cause crash with navigation map (invalid native peer) #673

Open
bgervan opened this issue May 20, 2021 · 0 comments
Labels

Comments

@bgervan
Copy link

bgervan commented May 20, 2021

Hi,

I am using mapbox-navigation-android with mapsnapshotter. I would like to add the navigation layers, but it drops "invalid native peer"

Sample code:

mapSnapshotter = MapSnapshotter(
                _navigationView.context, MapSnapshotter.Options(800, 400)
                    .withStyleBuilder(navigationMapboxMap.retrieveMap()?.style?.json?.let { navigationMapboxMap.retrieveMap()?.style?.getLayer("mapbox-location-bearing-layer")?.let { it1 ->
                        Style.Builder().withLayer(
                            it1
                        ).fromJson(it)
                    } })
                    .withCameraPosition(navigationMapboxMap.retrieveMap()?.cameraPosition))

The crash:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.important.mobilepro.dev, PID: 14913
    java.lang.IllegalStateException: invalid native peer
        at com.mapbox.mapboxsdk.snapshotter.MapSnapshotter.nativeAddLayerAbove(Native Method)
        at com.mapbox.mapboxsdk.snapshotter.MapSnapshotter.addLayerAbove(MapSnapshotter.java:515)
        at com.mapbox.mapboxsdk.snapshotter.MapSnapshotter.onDidFinishLoadingStyle(MapSnapshotter.java:785)
        at com.mapbox.mapboxsdk.snapshotter.MapSnapshotter.nativeInitialize(Native Method)
        at com.mapbox.mapboxsdk.snapshotter.MapSnapshotter.<init>(MapSnapshotter.java:424)
        at ...createSnapshot(MapComponent.kt:370)

I tried with withLayers etc, other layer id, all result the same.
Without the withLayer, the snapshot doesn't render the navigation layer, nor the car icon.

What does the invalid native peer mean?

@stale stale bot added the archived label Apr 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant