Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] 5.0.0.2083 crashes on GetClearButtonTintImage on devices running iOS < 14 #14439

Closed
danmiser opened this issue Jul 20, 2021 · 6 comments
Closed
Labels
p/iOS 🍎 s/unverified New report that has yet to be verified t/bug 🐛
Projects

Comments

@danmiser
Copy link

There is a new crash introduced in 5.0.0.2083 for iOS devices running versions of iOS less than 14.

To reproduce:

  1. In VS2019 Mac, create a New solution: Multiplatform, App, Blank. You can do iOS only as this bug does not appear in Android.
  2. In the MainPage.xaml, add this one control underneath one of the Label elements:
    <Entry TextColor="DarkRed" ClearButtonVisibility="WhileEditing" />
  3. Verify that the projected created is using Xamarin.Forms 5.0.0.2012
  4. Select a simulator prior to iOS 14, e.g. iPhone 5s iOS 12.2
  5. Run the application and note that everything works fine
  6. Upgrade the Xamarin.Forms packages in both projects to 5.0.0.2083
  7. Run
    //Expected: For the app to run as it did in the 2012 build, or in the Android builds
    //Actual: Crash with stack trace below
    NOTE: This works fine if you run on a simulator running iOS14.

System.NullReferenceException: Object reference not set to an instance of an object
at Xamarin.Forms.Platform.iOS.EntryRendererBase1[TControl].GetClearButtonTintImage (UIKit.UIImage image, UIKit.UIColor color) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\EntryRenderer.cs:591 at Xamarin.Forms.Platform.iOS.EntryRendererBase1[TControl].UpdateClearButtonColor () [0x00086] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\EntryRenderer.cs:581
at Xamarin.Forms.Platform.iOS.EntryRendererBase1[TControl].UpdateClearButtonVisibility () [0x00020] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\EntryRenderer.cs:559 at Xamarin.Forms.Platform.iOS.EntryRendererBase1[TControl].OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x001a5] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\EntryRenderer.cs:154 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x00172] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:296
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:158 at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240 at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:115 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:49 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x0012e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:283
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.iOS.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:158
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240
at Xamarin.Forms.Platform.iOS.VisualElementPackager.OnChildAdded (Xamarin.Forms.VisualElement view) [0x0003e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:115
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:49
at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x0008f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:251
at at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr)
at UIKit.UIViewController.get_View () [0x0002a] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UIViewController.g.cs:3211
at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:103
at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0003d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:119
at Xamarin.Forms.Platform.iOS.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x00032] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:240
at Xamarin.Forms.Platform.iOS.Platform.AddChild (Xamarin.Forms.VisualElement view) [0x00027] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:353
at Xamarin.Forms.Platform.iOS.Platform.WillAppear () [0x0003c] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Platform.cs:339
at Xamarin.Forms.Platform.iOS.PlatformRenderer.ViewWillAppear (System.Boolean animated) [0x00018] in D:\a\1\s\Xamarin.Forms.Platform.iOS\PlatformRenderer.cs:95
at at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend(intptr,intptr)
at UIKit.UIWindow.MakeKeyAndVisible () [0x0000d] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UIWindow.g.cs:289
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.SetMainPage () [0x00006] in D:\a\1\s\Xamarin.Forms.Platform.iOS\FormsApplicationDelegate.cs:181
at Xamarin.Forms.Platform.iOS.FormsApplicationDelegate.FinishedLaunching (UIKit.UIApplication uiApplication, Foundation.NSDictionary launchOptions) [0x00030] in D:\a\1\s\Xamarin.Forms.Platform.iOS\FormsApplicationDelegate.cs:57
at EntryTextColorCrash.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00013] in /Users/danmiser/code/EntryTextColorCrash/EntryTextColorCrash.iOS/AppDelegate.cs:28
at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65
at EntryTextColorCrash.iOS.Application.Main (System.String[] args) [0x00001] in /Users/danmiser/code/EntryTextColorCrash/EntryTextColorCrash.iOS/Main.cs:17

@danmiser danmiser added s/unverified New report that has yet to be verified t/bug 🐛 labels Jul 20, 2021
@jmichas
Copy link

jmichas commented Jul 21, 2021

@danmiser Just came across this same bug, any work around besides downgrading?

@danmiser
Copy link
Author

The path I took was to get rid of the clear button. But it looks like you could also remove the TextColor and leave it as Default. Only when both conditions are true will it crash as described

@jmichas
Copy link

jmichas commented Jul 21, 2021

Ok cool, thanks. I removed the clear button from my global style and bingo, working again.

@danmiser
Copy link
Author

danmiser commented Aug 2, 2021

Confirmed in a debug session, the following line is returning null in my iOS 12 simulator, but fully populated when using iOS 14.
_defaultClearImage = clearButton.ImageForState(UIControlState.Highlighted);

I don't see anything in the docs that tell me this method is new.

@PeterWaher
Copy link

We get the same error when we run our IdApp on iOS. (Works for Android).

https://github.com/Trust-Anchor-Group/IdApp

(You just need to run the app, and it happens during initialization/startup)

@jsuarezruiz jsuarezruiz added this to New in Triage via automation Aug 13, 2021
@jfversluis
Copy link
Member

Should be fixed in the next SR by #14566

Triage automation moved this from New to Closed Sep 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p/iOS 🍎 s/unverified New report that has yet to be verified t/bug 🐛
Projects
Triage
  
Closed
Development

No branches or pull requests

5 participants