XamarinCommunityToolkit icon indicating copy to clipboard operation
XamarinCommunityToolkit copied to clipboard

[Bug] NRE iOS IconTintColor when using hot reload

Open RemcoDEV opened this issue 3 years ago • 0 comments

Description

Xamarin apps crash when performing hot reload on an imagebutton that is having an icon tint color set.

Stack Trace

An error occurred: 'Object reference not set to an instance of an object.'. Callstack: ' at Xamarin.CommunityToolkit.iOS.Effects.IconTintColorEffectRouter.ClearTintColor () <0x1218fb888 + 0x0009a> in :0 at Xamarin.CommunityToolkit.iOS.Effects.IconTintColorEffectRouter.OnDetached () <0x1218fb768 + 0x00002> in :0 at Xamarin.Forms.Effect.SendDetached () [0x00009] in D:\a_work\1\s\Xamarin.Forms.Core\Effect.cs:62 at Xamarin.Forms.PlatformEffect2[TContainer,TControl].SendDetached () [0x00000] in D:\a\_work\1\s\Xamarin.Forms.Core\PlatformEffect.cs:23 at Xamarin.Forms.RoutingEffect.SendDetached () [0x00000] in D:\a\_work\1\s\Xamarin.Forms.Core\RoutingEffect.cs:34 at Xamarin.Forms.Element.set_EffectControlProvider (Xamarin.Forms.IEffectControlProvider value) [0x0002e] in D:\a\_work\1\s\Xamarin.Forms.Core\Element.cs:230 at Xamarin.Forms.Platform.iOS.EffectUtilities.RegisterEffectControlProvider (Xamarin.Forms.IEffectControlProvider self, Xamarin.Forms.IElementController oldElement, Xamarin.Forms.IElementController newElement) [0x0000e] in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\EffectUtilities.cs:16 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x00194] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:301 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) [0x0008c] in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:397 at Xamarin.Forms.Platform.iOS.ViewRenderer2[TView,TNativeView].Dispose (System.Boolean disposing) [0x0005c] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\ViewRenderer.cs:124 at Xamarin.Forms.Platform.iOS.ImageButtonRenderer.Dispose (System.Boolean disposing) [0x0002d] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\ImageButtonRenderer.cs:58 at Foundation.NSObject.Dispose () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSObject2.cs:218 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose (System.Boolean disposing) [0x0003f] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:91 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose () [0x00000] in D:\a_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:41 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) [0x00058] in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:388 at Foundation.NSObject.Dispose () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSObject2.cs:218 at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildRemoved (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:143 at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildRemoved (System.Object sender, Xamarin.Forms.ElementEventArgs e) [0x0000f] in D:\a\_work\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:205 at (wrapper delegate-invoke) System.EventHandler1[Xamarin.Forms.ElementEventArgs].invoke_void_object_TEventArgs(object,Xamarin.Forms.ElementEventArgs) at Xamarin.Forms.Element.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00007] in D:\a_work\1\s\Xamarin.Forms.Core\Element.cs:344 at Xamarin.Forms.VisualElement.OnChildRemoved (Xamarin.Forms.Element child, System.Int32 oldLogicalIndex) [0x00000] in D:\a_work\1\s\Xamarin.Forms.Core\VisualElement.cs:847 at Xamarin.Forms.Layout.OnInternalRemoved (Xamarin.Forms.View view, System.Int32 oldIndex) [0x00012] in D:\a_work\1\s\Xamarin.Forms.Core\Layout.cs:455 at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0002b] in D:\a_work\1\s\Xamarin.Forms.Core\Layout.cs:418 at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263 at System.Collections.ObjectModel.ObservableCollection1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338 at System.Collections.ObjectModel.ObservableCollection1[T].RemoveItem (System.Int32 index) [0x00021] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:182 at System.Collections.ObjectModel.Collection1[T].Remove (T item) [0x00027] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:128 at Xamarin.Forms.ContentPresenter.OnContentChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00034] in D:\a_work\1\s\Xamarin.Forms.Core\ContentPresenter.cs:84 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 at (wrapper delegate-invoke) <Module>.invoke_void_object(object) at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:178

Link to Reproduction Sample

Steps to Reproduce

  1. Add a tint color to an imagebutton <Setter Property="effects:IconTintColorEffect.TintColor" Value="{StaticResource AlwaysWhiteTextColor}" />
  2. Perform hot reload upon this imagebutton (change background color for example).
  3. Crash

Expected Behavior

It should not crash.

Actual Behavior

It crashes.

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:
    • iOS:
    • Android:
    • UWP:
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:

Workaround

Reproduction imagery

RemcoDEV avatar May 18 '22 08:05 RemcoDEV