-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
place a map on a content page. Display the page and move around on the map, it works properly. close the page and reopen it. move around on the map. Either VisibleRegion will not be updated or the following exception will be thrown:
[0:] An error occurred: 'VirtualView cannot be null here'. Callstack: ' at Microsoft.Maui.Handlers.ViewHandler2[[Microsoft.Maui.Maps.IMap, Microsoft.Maui.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Maps.Platform.MauiMKMapView, Microsoft.Maui.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_VirtualView() at Microsoft.Maui.Maps.Handlers.MapHandler.Microsoft.Maui.Maps.Handlers.IMapHandler.get_VirtualView() at Microsoft.Maui.Maps.Platform.MauiMKMapView.MkMapViewOnRegionChanged(Object sender, MKMapViewChangeEventArgs e) at MapKit.MKMapView._MKMapViewDelegate.RegionChanged(MKMapView mapView, Boolean animated) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/MapKit/MKMapView.g.cs:line 1970 at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 61 at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 96 at MauiDev.Program.Main(String[] args) in C:\Dev\Projects\MauiDev\MauiDev\Platforms\iOS\Program.cs:line 12 at System.Object.InvokeStub_Program.Main(Object , Span1 )
at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)'
Steps to Reproduce
I used the following code to test the VisibleRegion:
`using System.Runtime.CompilerServices;
using Maps = Microsoft.Maui.Controls.Maps;
namespace MauiDev.Widgets;
public partial class MapBaseBug : Maps.Map
{
protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
base.OnPropertyChanged(propertyName);
if (propertyName == nameof(VisibleRegion))
{
Trace.WriteLine($"Visible Region is null {VisibleRegion == null}");
}
}
}
`
The first time i open a page with the map on it and pan around I get the messages in the log. The second time I don't get the messages and usually get the exception.
Link to public reproduction project repository
No response
Version with bug
9.0.70 SR7
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 18.5
Did you find any workaround?
No.