oxyplot / oxyplot-xamarin

OxyPlot for Xamarin.Mac and Xamarin.Forms
MIT License
64 stars 59 forks source link

iOS: This PlotModel is already in use by some other PlotView control. #144

Open janusw opened 1 year ago

janusw commented 1 year ago

This is similar to #139, but on iOS ...

Apparently the exceptions regarding "This PlotModel is already in use ..." do not only occur on MacOS, but sometimes also on iOS (although I don't quite understand under which circumstances this happens yet).

The following stack trace is from an application that uses a PlotView inside a TableView:

    IPlotModel.AttachPlotView (OxyPlot.IPlotView plotView)
    PlotView.set_Model (OxyPlot.PlotModel value)
    PlotViewRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1[TElement] e)
    VisualElementRenderer`1[TElement].SetElement (TElement element)
    IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element)
    Platform.CreateRenderer (Xamarin.Forms.VisualElement element)
    ViewCellRenderer+ViewTableCell.GetNewRenderer ()
    ViewCellRenderer+ViewTableCell.UpdateCell (Xamarin.Forms.ViewCell cell)
    ViewCellRenderer+ViewTableCell.set_ViewCell (Xamarin.Forms.ViewCell value)
    ViewCellRenderer.GetCell (Xamarin.Forms.Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv)
    CellTableViewCell.GetNativeCell (UIKit.UITableView tableView, Xamarin.Forms.Cell cell, System.Boolean recycleCells, System.String templateId)
    TableViewModelRenderer.GetCell (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath)
    (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&)
    UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName)
    UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName)
    Application.Main (System.String[] args)

I have only seen this happen with 2.0.0-beta.1 so far, but it probably also happens with 2.0.0 and 2.1.0 (?).