Skip to content

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

Closed

Description

@mahesh139

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

Activity

  1. 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)[/+] on Nov 6, 2024
  2. mahesh139 commented on Nov 6, 2024

    @mahesh139
    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) => { }

  3. 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)[/+] on Nov 7, 2024
  4. locked and limited conversation to collaborators on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/viewsIssue/Discussion/PR that has to do with ViewsbugSomething isn't workingunverified

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions