Issue category: Lightship Maps Maps Version : 0.4.0
Device type & OS version: iOS, iPhone 14 Pro
Host machine & OS version: Mac
Issue Environment : On Device
The map will work perfectly on the first load, but when I return after a scene reload the map tiles won’t load and the whole scene gets pixelated? Bizare behavior. (see video)
NullReferenceException: Object reference not set to an instance of an object.
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].PositionInstance (T instance, Niantic.Lightship.Maps.Core.Coordinates.LatLng& location, UnityEngine.Quaternion& rotation) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.Internal.MapUnitConverter.set_MapOrigin (Niantic.Lightship.Maps.Core.Coordinates.LatLng value) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetViewableAreaInternal (Niantic.Lightship.Maps.Core.Coordinates.LatLng& latLng, System.Double mapRadius) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetMapCenter (UnityEngine.Vector3 center) [0x00000] in <00000000000000000000000000000000>:0
at PlayerLocationController.Update () [0x00000] in <00000000000000000000000000000000>:0 ```
I’m sorry to hear you’re having trouble with Maps. Are you using the RefreshMap or ReloadMap methods in LightshipMapView? Could I see how you’re switching scenes and the code related to making the map reappear?
I have a bootstrapper scene that loads the map scene additively. I am not using ReloadMap or RefreshMap, simply letting the LightshipMap gameobject instantiate normally on scene load. I’ve narrowed the issue down to my custom map placement layers, when I disable both of them the map loads fine. This is also where the exception is getting thrown in the Lightship maps code (see NullReferenceException referenced above).
This exception is only happening on device (iOS), it works fine in the editor.
When you deploy to your iPhone, are you using a development build? From looking at the code, it looks like LayerPrefabPlacementBase Line 151 under PositionInstance where it calls GetTransform is causing the error; this means that somehow the instance of your outpost is resolving to null. Can you add a log message above the GetTransform call to see if instance is null as I suspect? In addition, in LightshipMapView in DetachAndHideChildObjects can you add a debug line above the while loop so we can see if that method is being called prior to the instance(s) becoming null? Please try this in the editor and on your iPhone with the development build flag enabled so you can see the printouts.
Then the LayerPrefabPlacementBase instantiates/places the 5 VPS markers correctly. However, once OnMapOriginChanged starts getting called all the instances are null.
Full Xcode output (once the map loads for the 2nd time - when the NR exceptions start)
Xcode output cont. OnMapOriginChanged is trying to update all the positions, but somehow all the instances have become null.
PositionInstance: instance = null
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:PositionInstance(T, LatLng&, Quaternion&)
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:OnMapOriginChanged()
System.Collections.Generic.List`1:ForEach(Action`1)
System.Collections.Generic.List`1:ForEach(Action`1)
Niantic.Lightship.Maps.LightshipMapView:OnMapOriginChanged()
Niantic.Lightship.Maps.Internal.MapUnitConverter:set_MapOrigin(LatLng)
Niantic.Lightship.Maps.LightshipMapView:SetViewableAreaInternal(LatLng&, Double)
Niantic.Lightship.Maps.LightshipMapView:SetMapCenter(Vector3)
PlayerLocationController:Update()
NullReferenceException: Object reference not set to an instance of an object.
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].PositionInstance (T instance, Niantic.Lightship.Maps.Core.Coordinates.LatLng& location, UnityEngine.Quaternion& rotation) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.Internal.MapUnitConverter.set_MapOrigin (Niantic.Lightship.Maps.Core.Coordinates.LatLng value) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetViewableAreaInternal (Niantic.Lightship.Maps.Core.Coordinates.LatLng& latLng, System.Double mapRadius) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetMapCenter (UnityEngine.Vector3 center) [0x00000] in <00000000000000000000000000000000>:0
at PlayerLocationController.Update () [0x00000] in <00000000000000000000000000000000>:0
PositionInstance: instance = null
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:PositionInstance(T, LatLng&, Quaternion&)
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:OnMapOriginChanged()
System.Collections.Generic.List`1:ForEach(Action`1)
System.Collections.Generic.List`1:ForEach(Action`1)
Niantic.Lightship.Maps.LightshipMapView:OnMapOriginChanged()
Niantic.Lightship.Maps.Internal.MapUnitConverter:set_MapOrigin(LatLng)
Niantic.Lightship.Maps.LightshipMapView:SetViewableAreaInternal(LatLng&, Double)
Niantic.Lightship.Maps.LightshipMapView:SetMapCenter(Vector3)
PlayerLocationController:Update()
NullReferenceException: Object reference not set to an instance of an object.
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].PositionInstance (T instance, Niantic.Lightship.Maps.Core.Coordinates.LatLng& location, UnityEngine.Quaternion& rotation) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.Internal.MapUnitConverter.set_MapOrigin (Niantic.Lightship.Maps.Core.Coordinates.LatLng value) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetViewableAreaInternal (Niantic.Lightship.Maps.Core.Coordinates.LatLng& latLng, System.Double mapRadius) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetMapCenter (UnityEngine.Vector3 center) [0x00000] in <00000000000000000000000000000000>:0
at PlayerLocationController.Update () [0x00000] in <00000000000000000000000000000000>:0
PositionInstance: instance = null
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:PositionInstance(T, LatLng&, Quaternion&)
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:OnMapOriginChanged()
System.Collections.Generic.List`1:ForEach(Action`1)
System.Collections.Generic.List`1:ForEach(Action`1)
Niantic.Lightship.Maps.LightshipMapView:OnMapOriginChanged()
Niantic.Lightship.Maps.Internal.MapUnitConverter:set_MapOrigin(LatLng)
Niantic.Lightship.Maps.LightshipMapView:SetViewableAreaInternal(LatLng&, Double)
Niantic.Lightship.Maps.LightshipMapView:SetMapCenter(Vector3)
PlayerLocationController:Update()
NullReferenceException: Object reference not set to an instance of an object.
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].PositionInstance (T instance, Niantic.Lightship.Maps.Core.Coordinates.LatLng& location, UnityEngine.Quaternion& rotation) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.Internal.MapUnitConverter.set_MapOrigin (Niantic.Lightship.Maps.Core.Coordinates.LatLng value) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetViewableAreaInternal (Niantic.Lightship.Maps.Core.Coordinates.LatLng& latLng, System.Double mapRadius) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetMapCenter (UnityEngine.Vector3 center) [0x00000] in <00000000000000000000000000000000>:0
at PlayerLocationController.Update () [0x00000] in <00000000000000000000000000000000>:0
PositionInstance: instance = null
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:PositionInstance(T, LatLng&, Quaternion&)
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:OnMapOriginChanged()
System.Collections.Generic.List`1:ForEach(Action`1)
System.Collections.Generic.List`1:ForEach(Action`1)
Niantic.Lightship.Maps.LightshipMapView:OnMapOriginChanged()
Niantic.Lightship.Maps.Internal.MapUnitConverter:set_MapOrigin(LatLng)
Niantic.Lightship.Maps.LightshipMapView:SetViewableAreaInternal(LatLng&, Double)
Niantic.Lightship.Maps.LightshipMapView:SetMapCenter(Vector3)
PlayerLocationController:Update()
NullReferenceException: Object reference not set to an instance of an object.
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].PositionInstance (T instance, Niantic.Lightship.Maps.Core.Coordinates.LatLng& location, UnityEngine.Quaternion& rotation) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.Internal.MapUnitConverter.set_MapOrigin (Niantic.Lightship.Maps.Core.Coordinates.LatLng value) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetViewableAreaInternal (Niantic.Lightship.Maps.Core.Coordinates.LatLng& latLng, System.Double mapRadius) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetMapCenter (UnityEngine.Vector3 center) [0x00000] in <00000000000000000000000000000000>:0
at PlayerLocationController.Update () [0x00000] in <00000000000000000000000000000000>:0
PositionInstance: instance = null
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:PositionInstance(T, LatLng&, Quaternion&)
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:OnMapOriginChanged()
System.Collections.Generic.List`1:ForEach(Action`1)
System.Collections.Generic.List`1:ForEach(Action`1)
Niantic.Lightship.Maps.LightshipMapView:OnMapOriginChanged()
Niantic.Lightship.Maps.Internal.MapUnitConverter:set_MapOrigin(LatLng)
Niantic.Lightship.Maps.LightshipMapView:SetViewableAreaInternal(LatLng&, Double)
Niantic.Lightship.Maps.LightshipMapView:SetMapCenter(Vector3)
PlayerLocationController:Update()
NullReferenceException: Object reference not set to an instance of an object.
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].PositionInstance (T instance, Niantic.Lightship.Maps.Core.Coordinates.LatLng& location, UnityEngine.Quaternion& rotation) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.Internal.MapUnitConverter.set_MapOrigin (Niantic.Lightship.Maps.Core.Coordinates.LatLng value) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetViewableAreaInternal (Niantic.Lightship.Maps.Core.Coordinates.LatLng& latLng, System.Double mapRadius) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetMapCenter (UnityEngine.Vector3 center) [0x00000] in <00000000000000000000000000000000>:0
at PlayerLocationController.Update () [0x00000] in <00000000000000000000000000000000>:0
PositionInstance: instance = null
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:PositionInstance(T, LatLng&, Quaternion&)
Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1:OnMapOriginChanged()
System.Collections.Generic.List`1:ForEach(Action`1)
System.Collections.Generic.List`1:ForEach(Action`1)
Niantic.Lightship.Maps.LightshipMapView:OnMapOriginChanged()
Niantic.Lightship.Maps.Internal.MapUnitConverter:set_MapOrigin(LatLng)
Niantic.Lightship.Maps.LightshipMapView:SetViewableAreaInternal(LatLng&, Double)
Niantic.Lightship.Maps.LightshipMapView:SetMapCenter(Vector3)
PlayerLocationController:Update()
NullReferenceException: Object reference not set to an instance of an object.
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].PositionInstance (T instance, Niantic.Lightship.Maps.Core.Coordinates.LatLng& location, UnityEngine.Quaternion& rotation) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.MapLayers.Components.BaseTypes.LayerPrefabPlacementBase`1[T].OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.OnMapOriginChanged () [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.Internal.MapUnitConverter.set_MapOrigin (Niantic.Lightship.Maps.Core.Coordinates.LatLng value) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetViewableAreaInternal (Niantic.Lightship.Maps.Core.Coordinates.LatLng& latLng, System.Double mapRadius) [0x00000] in <00000000000000000000000000000000>:0
at Niantic.Lightship.Maps.LightshipMapView.SetMapCenter (UnityEngine.Vector3 center) [0x00000] in <00000000000000000000000000000000>:0
at PlayerLocationController.Update () [0x00000] in <00000000000000000000000000000000>:0
Regardless of the issue, one suggestion would be to make the map more fault tolerant. If for some reason instance in PositionInstance() is null, it should not crash the entire map. I’m assuming it was designed such that instance would never be null though.
We were out of office because of the Independence Day holiday. Maps is supposed to be fault-tolerant, so what you’re encountering is a bug and unintended behavior.
I have a couple workarounds you can try:
Delete your placed instances on scene change and place them again when the scene returns to the map.
Delete the entire map on scene change and recreate it when the game should show the map again.
API calls can be expensive and slow. You only need to do the VPS Coverage API calls once and then cache them if you’re going to use either of the workarounds. That way you don’t have to call the API every single time.
I will make a note of this bug and pass it along for our engineering team to look over.