mapbox-unity-sdk icon indicating copy to clipboard operation
mapbox-unity-sdk copied to clipboard

Switching TileProvider at runtime will cause NullReference for Transform or Camera Providers

Open Markovicho opened this issue 3 years ago • 2 comments

We want to switch TileProvider at runtime which is generally working fine. But ....

  1. Configure RangeAroundCenter Provider intially via AbstractMap Editor GUI
  2. Switch to transformtileprovider or cameratileprovider at runtime via script WITHOUT setting any references in the gui editor before
CameraBoundsTileProviderOptions options = new CameraBoundsTileProviderOptions();
options.camera = MyCamera;
Map.SetExtent(MapExtentType.CameraBounds,options);

RangeAroundTransformTileProviderOptions options = new RangeAroundTransformTileProviderOptions();
options.SetOptions(MyTransform);
Map.SetExtent(MapExtentType.RangeAroundTransform,options);

this will result in a NullReferenceException based on an empty field for the camera/transform reference in the provideroptions. It seems like mapbox is switching the provider without taking respect to the passed options and try's to render the next map update already which results in crashing.

My workaround:

preconfigure the tileprovider in the editor with dummy transform/camera. The field is not empty so everything is fine until the new options will be set. But that should be fixed in the framework.

image

to

image

Markovicho avatar Oct 04 '21 08:10 Markovicho

I think this is using performance branch, right? I believe only Camera Bounds tile provider is working in that branch and others are broken at the moment. I might have fixed the errors in RangeAroundCenter I guess but only that and it's probably not in the best shape. I'll try to look into this soon but can't give an ETA at the moment I'm afraid.

brnkhy avatar Oct 08 '21 11:10 brnkhy

It's still the case on performance branch but i discovered this issue already on the latest stable release.

Markovicho avatar Oct 08 '21 20:10 Markovicho