Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] DrawingView Error : PlatformView cannot be null here when used with BindableLayout (Android and iOS) #2320

Open
2 tasks done
mahesh139 opened this issue Nov 6, 2024 · 1 comment
Labels
bug Something isn't working unverified

Comments

@mahesh139
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

Application crashes with PlatformView cannot be null here when drawing view is used inside bindable layout. app crashes while changing the item source of the bindable layout. This happens on both Android and iOS.

Error Started after upgrading to Microsoft.Maui.Controls 8.0.60+ (latest release 8.0.92 also has same problem.)

Please find Git repo that produces same error:
https://github.com/mahesh139/MAUIBugs

This was working fine with Microsoft.Maui.Controls 8.0.40

Expected Behavior

Changing bindable layout item source that contains drawing view must not crash.

Steps To Reproduce

  1. Open and run the solution.
  2. Click on "Section 2" button, this will change bindable layout item source (no items in source)
  3. Click on "Section 1" button, App crashes with PlatformView cannot be null here error while changing item source.

Hope this video helps with re-production steps:
https://github.com/user-attachments/assets/ec693e41-b910-4d36-9d4c-12a6f7489072

Link to public reproduction project repository

https://github.com/mahesh139/MAUIBugs

Environment

  • .NET MAUI CommunityToolkit:9.1.0
  • OS: Win 10
  • .NET MAUI:8
  • Microsoft.Maui.Controls 8.0.92
  • Microsoft.Maui.Controls.Compatibility 8.0.92

Anything else?

Same repo works fine for:
CommunityToolkit.Maui 9.0.0
Microsoft.Maui.Controls 8.0.40
Microsoft.Maui.Controls.Compatibility 8.0.40

@mahesh139 mahesh139 added bug Something isn't working unverified labels Nov 6, 2024
@mahesh139 mahesh139 changed the title [BUG] Drawing View Error : PlatformView cannot be null here (Android and iOS) [BUG] DrawingView Error : PlatformView cannot be null here (Android and iOS) Nov 6, 2024
@mahesh139
Copy link
Author

Exception Log:

System.InvalidOperationException
PlatformView cannot be null here

void DrawingViewHandler.OnVirtualViewLinesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
In App

Assembly:
CommunityToolkit.Maui.Core
Version:
1.0.0.0
Called from: ObservableCollection.cs in void ObservableCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)

Show 3 more frames

void MauiDrawingViewExtensions.SetLines(IDrawingView drawingView, MauiDrawingView mauiDrawingView, IDrawingLineAdapter adapter)
In App

void DrawingViewHandler.OnPlatformViewLinesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
In App

Called from: ObservableCollection.cs in void ObservableCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)

Show 3 more frames

void MauiDrawingViewExtensions.SetLines(MauiDrawingView mauiDrawingView, IDrawingView drawingView)
In App

void DrawingViewHandler.MapLines(DrawingViewHandler handler, IDrawingView view)
In App

Called from: /_/src/Core/src/PropertyMapper.cs in void PropertyMapper<TVirtualView, TViewHandler>.Add(string key, Action<TViewHandler, TVirtualView> action)+(IElementHandler h, IElement v) => { }

Show 32 more frames

/_/MvvmHelpers/ObservableRangeCollection.cs in void ObservableRangeCollection.RaiseChangeNotificationEvents(NotifyCollectionChangedAction action, List changedItems, int startingIndex) at line 160:17
In App

/_/MvvmHelpers/ObservableRangeCollection.cs in void ObservableRangeCollection.ReplaceRange(IEnumerable collection) at line 140:4
In App

ViewModels\TestViewModel.cs in void TestViewModel.SetSection1Answers() at line 42:13
In App

ViewModels\TestViewModel.cs in void TestViewModel.RegisterCommands()+() => { } [0] at line 55:17
In App

Called from: /_/src/Controls/src/Core/Command.cs in Command(Action execute)+(object o) => { }

@mahesh139 mahesh139 changed the title [BUG] DrawingView Error : PlatformView cannot be null here (Android and iOS) [BUG] DrawingView Error : PlatformView cannot be null here when used with BindableLayout (Android and iOS) Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unverified
Projects
None yet
Development

No branches or pull requests

1 participant