Skip to content

[iOS] HTML Label in a Carousel View causes a NSInternalInconsistencyException when carousel is swiped. #29913

Open
@czuck

Description

@czuck

Description

When a label of TextType="Html" is added to a Carousel and the carousel is swiped, the app crashes with a NSInternalInconsistencyException error.

Steps to Reproduce

Run the app in the test app linked below.
From the hamburger menu choose "Carousel" to open the monkey carousel. Swipe the carousel, the exception will be thrown.
Edit \Pages\CarouselPage and remove the 'TextType="Html"' from the last label in the Carousel and retest. The Carousel will work.

Link to public reproduction project repository

https://github.com/czuck/MauiTest.git

Version with bug

9.0.70 SR7

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

ObjCRuntime.ObjCException
  Message=Objective-C exception thrown.  Name: NSInternalInconsistencyException Reason: Expected dequeued view to be returned to the collection view in preparation for display. When the collection view's data source is asked to provide a view for a given index path, ensure that a single view is dequeued and returned to the collection view. Avoid dequeuing views without a request from the collection view. For retrieving an existing view in the collection view, use -[UICollectionView cellForItemAtIndexPath:] or -[UICollectionView supplementaryViewForElementKind:atIndexPath:]. Dequeued view: <Microsoft_Maui_Controls_Handlers_Items_CarouselTemplatedCell: 0x13cde9e00; baseClass = UICollectionViewCell; frame = (10638 0; 394 896); layer = <CALayer: 0x13ced3c20>>; Collection view: <Microsoft_Maui_Controls_Handlers_Items_MauiCollectionView: 0x13d068000; baseClass = UICollectionView; frame = (0 0; 394 896); clipsToBounds = YES; autoresize = W+H; gestureRecognizers = <NSArray: 0x13cecb810>; backgroundColor = UIExtendedGrayColorSpace 0 0; layer = <CALayer: 0x13cb46de0>; contentOffset: {10049, 0}; contentSize: {20094, 896}; adjustedContentInset: {0, 0, 0, 0}; layout: <Microsoft_Maui_Controls_Handlers_Items_CarouselViewLayout: 0x13cde8a00>; dataSource: <Microsoft_Maui_Controls_Handlers_Items_CarouselViewController: 0x13c48ad00>>
Native stack trace:
	0   CoreFoundation                      0x0000000185de3228 7821F73C-378B-3A10-BE90-EF526B7DBA93 + 1155624
	1   libobjc.A.dylib                     0x000000018327dabc objc_exception_throw + 88
	2   Foundation                          0x00000001850e1670 34DE055D-8683-380A-9198-C3347211D13D + 7988848
	3   UIKitCore                           0x00000001890138c8 96636F64-106F-30C8-A780-82DCEBB0F443 + 10860744
	4   UIKitCore                           0x00000001888cf0a4 96636F64-106F-30C8-A780-82DCEBB0F443 + 3240100
	5   UIKitCore                           0x00000001888d48a4 96636F64-106F-30C8-A780-82DCEBB0F443 + 3262628
	6   UIKitCore                           0x000000018885e590 96636F64-106F-30C8-A780-82DCEBB0F443 + 2778512
	7   UIKitCore                           0x00000001885de070 96636F64-106F-30C8-A780-82DCEBB0F443 + 155760
	8   QuartzCore                          0x0000000187855c14 109010DA-3C35-3E22-B001-939786412EE2 + 85012
	9   QuartzCore                          0x000000018785558c 109010DA-3C35-3E22-B001-939786412EE2 + 83340
	10  QuartzCore                          0x00000001878577f8 109010DA-3C35-3E22-B001-939786412EE2 + 92152
	11  QuartzCore                          0x0000000187856cc0 109010DA-3C35-3E22-B001-939786412EE2 + 89280
	12  QuartzCore                          0x0000000187856938 109010DA-3C35-3E22-B001-939786412EE2 + 88376
	13  UIKitCore                           0x00000001885c1e70 96636F64-106F-30C8-A780-82DCEBB0F443 + 40560
	14  UIKitCore                           0x00000001885c1e0c 96636F64-106F-30C8-A780-82DCEBB0F443 + 40460
	15  UIKitCore                           0x00000001885c1404 96636F64-106F-30C8-A780-82DCEBB0F443 + 37892
	16  UIKitCore                           0x00000001885c0ab4 96636F64-106F-30C8-A780-82DCEBB0F443 + 35508
	17  UIKitCore                           0x00000001885bc1e4 96636F64-106F-30C8-A780-82DCEBB0F443 + 16868
	18  CoreFoundation                      0x0000000185cd8a8c 7821F73C-378B-3A10-BE90-EF526B7DBA93 + 64140
	19  CoreFoundation                      0x0000000185cd88a4 7821F73C-378B-3A10-BE90-EF526B7DBA93 + 63652
	20  CoreFoundation                      0x0000000185cd8764 7821F73C-378B-3A10-BE90-EF526B7DBA93 + 63332
	21  CoreFoundation                      0x0000000185cd9080 7821F73C-378B-3A10-BE90-EF526B7DBA93 + 65664
	22  CoreFoundation                      0x0000000185cdac3c CFRunLoopRunSpecific + 572
	23  UIFoundation                        0x00000001919aadec 8AF827AD-7C15-3216-B6AD-9788252CBC9A + 929260
	24  UIFoundation                        0x00000001919ab968 8AF827AD-7C15-3216-B6AD-9788252CBC9A + 932200
	25  UIFoundation                        0x0000000191960cc4 8AF827AD-7C15-3216-B6AD-9788252CBC9A + 625860
	26  UIFoundation                        0x000000019195ccd0 _NSReadAttributedStringFromURLOrData + 288
	27  UIFoundation                        0x000000019195cb48 8AF827AD-7C15-3216-B6AD-9788252CBC9A + 609096
	28  CleanApp                            0x000000010465f080 xamarin_dyn_objc_msgSend + 160
	29  CleanApp                            0x0000000104870748 do_icall + 368
	30  CleanApp                            0x000000010486ece8 do_icall_wrapper + 348
	31  CleanApp                            0x0000000104862260 mono_interp_exec_method + 2580
	32  CleanApp                            0x000000010485f618 interp_entry_from_trampoline + 656
	33  CleanApp                            0x0000000104615970 native_to_interp_trampoline + 112
	34  CleanApp                            0x00000001048b1338 -[Microsoft_Maui_Controls_Handlers_Items_CarouselViewController collectionView:cellForItemAtIndexPath:] + 116
	35  UIKitCore                           0x0000000189010fec 96636F64-106F-30C8-A780-82DCEBB0F443 + 10850284
	36  UIKitCore                           0x00000001885ed2b4 96636F64-106F-30C8-A780-82DCEBB0F443 + 217780
	37  UIKitCore                           0x0000000188969c44 96636F64-106F-30C8-A780-82DCEBB0F443 + 3873860
	38  UIKitCore                           0x00000001890112d0 96636F64-106F-30C8-A780-82DCEBB0F443 + 10851024
	39  UIKitCore                           0x00000001889c11f4 96636F64-106F-30C8-A780-82DCEBB0F443 + 4231668
	40  UIKitCore                           0x0000000189012c38 96636F64-106F-30C8-A780-82DCEBB0F443 + 10857528
	41  UIKitCore                           0x00000001893cad9c 96636F64-106F-30C8-A780-82DCEBB0F443 + 14757276
	42  libdispatch.dylib                   0x000000018dc54aac 395DA84F-715D-334E-8D41-A16CD93FC83C + 6828
	43  libdispatch.dylib                   0x000000018dc6e584 395DA84F-715D-334E-8D41-A16CD93FC83C + 112004
	44  libdispatch.dylib                   0x000000018dc8b5a0 395DA84F-715D-334E-8D41-A16CD93FC83C + 230816
	45  libdispatch.dylib                   0x000000018dc63d30 395DA84F-715D-334E-8D41-A16CD93FC83C + 68912
	46  libdispatch.dylib                   0x000000018dc63c6c _dispatch_main_queue_callback_4CF + 44
	47  CoreFoundation                      0x0000000185d35d90 7821F73C-378B-3A10-BE90-EF526B7DBA93 + 445840
	48  CoreFoundation                      0x0000000185cd94f4 7821F73C-378B-3A10-BE90-EF526B7DBA93 + 66804
	49  CoreFoundation                      0x0000000185cdac3c CFRunLoopRunSpecific + 572
	50  GraphicsServices                    0x00000001d2eb9454 GSEventRunModal + 168
	51  UIKitCore                           0x00000001886ed274 96636F64-106F-30C8-A780-82DCEBB0F443 + 1266292
	52  UIKitCore                           0x00000001886b8a28 UIApplicationMain + 336
	53  CleanApp                            0x000000010462c5a4 xamarin_UIApplicationMain + 60
	54  CleanApp                            0x0000000104870714 do_icall + 316
	55  CleanApp                            0x000000010486ece8 do_icall_wrapper + 348
	56  CleanApp                            0x0000000104862260 mono_interp_exec_method + 2580
	57  CleanApp                            0x000000010485fe1c interp_runtime_invoke + 236
	58  CleanApp                            0x000000010482e6f4 mono_jit_runtime_invoke + 1244
	59  CleanApp                            0x00000001047d6500 mono_runtime_invoke_checked + 148
	60  CleanApp                            0x00000001047dc404 mono_runtime_exec_main_checked + 116
	61  CleanApp                            0x0000000104835110 mono_jit_exec + 356
	62  CleanApp                            0x000000010465dbf4 xamarin_main + 2028
	63  CleanApp                            0x00000001048a1450 main + 64
	64  dyld                                0x00000001acbaff08 86D5253D-4FD1-36F3-B4AB-25982C90CBF4 + 257800

  Source=<unknown>
  StackTrace:
   at Foundation.NSAttributedString..ctor(NSData data, NSDictionary options, NSDictionary& resultDocumentAttributes, NSError& error) in /Users/builder/azdo/_work/7/s/macios/src/build/dotnet/ios/generated-sources/Foundation/NSAttributedString.g.cs:line 238
   at Foundation.NSAttributedString..ctor(NSData data, NSAttributedStringDocumentAttributes options, NSDictionary& resultDocumentAttributes, NSError& error) in /Users/builder/azdo/_work/7/s/macios/src/build/dotnet/ios/generated-sources/Foundation/NSAttributedString.g.cs:line 258
   at Foundation.NSAttributedString..ctor(NSData data, NSAttributedStringDocumentAttributes documentAttributes, NSError& error) in /Users/builder/azdo/_work/7/s/macios/src/Foundation/NSAttributedString.cs:line 209
   at Microsoft.Maui.Platform.LabelExtensions.UpdateTextHtml(UILabel platformLabel, ILabel label)
   at Microsoft.Maui.Controls.Platform.LabelExtensions.UpdateText(UILabel platformLabel, Label label)
   at Microsoft.Maui.Controls.Label.MapText(ILabelHandler handler, Label label)
   at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass2_0`2[[Microsoft.Maui.Controls.Label, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.ILabelHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<ReplaceMapping>b__0(ILabelHandler h, Label v, Action`2 p)
   at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass1_0`2[[Microsoft.Maui.Controls.Label, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.ILabelHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<ModifyMapping>g__newMethod|0(IElementHandler handler, IElement view)
   at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.ILabel, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.ILabelHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v)
   at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView)
   at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILabel, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiLabel, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILabel, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiLabel, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer`1[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].ProcessAutoPackage(IElement element)
   at Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer`1[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view, IPlatformViewHandler nativeViewHandler, Action`1 onElementChanged, Frame& currentVirtualView, IPropertyMapper& _mapper, IPropertyMapper _defaultMapper, Boolean autoPackage)
   at Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer`1[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Microsoft.Maui.IElementHandler.SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context)
   at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view)
   at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view)
   at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler)
   at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value)
   at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value)
   at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context)
   at Microsoft.Maui.Platform.ViewExtensions.ToHandler(IView view, IMauiContext context)
   at Microsoft.Maui.Controls.Handlers.Items.TemplateHelpers.GetHandler(View view, IMauiContext context)
   at Microsoft.Maui.Controls.Handlers.Items.TemplatedCell.Bind(DataTemplate template, Object bindingContext, ItemsView itemsView)
   at Microsoft.Maui.Controls.Handlers.Items.ItemsViewController`1[[Microsoft.Maui.Controls.CarouselView, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].UpdateTemplatedCell(TemplatedCell cell, NSIndexPath indexPath)
   at Microsoft.Maui.Controls.Handlers.Items.CarouselViewController.GetCell(UICollectionView collectionView, NSIndexPath indexPath)
   at Microsoft.Maui.Controls.Handlers.Items.CarouselViewController.__Registrar_Callbacks__.callback_124_Microsoft_Maui_Controls_Handlers_Items_CarouselViewController_GetCell(IntPtr pobj, IntPtr sel, IntPtr p0, IntPtr p1, IntPtr* exception_gchandle)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions