Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
This repository was 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

Description

@bgervan

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions