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

NSInternalInconsistencyException Reason: UIGraphicsBeginImageContext() failed to allocate CGBitampContext #15827

Closed
AlleSchonWeg opened this issue Oct 12, 2023 · 30 comments · Fixed by #15833
Labels
iOS 17 Issues/PRs that are specific to iOS 17/Xcode 15 t/bug 🐛

Comments

@AlleSchonWeg
Copy link
Contributor

AlleSchonWeg commented Oct 12, 2023

Hi,
we just updated VS for Mac (17.6.5) today and now the xf app crashes. It looks like an Xcode 15 problem, because with Xcode 14 the app runs successfully.
Here is the error message:
Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={0, 0}, scale=3.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert.

And the native stack trace:
Native stack trace:

0 CoreFoundation 0x000000010dad328d __exceptionPreprocess + 242
1 libobjc.A.dylib 0x0000000123d9e894 objc_exception_throw + 48
2 Foundation 0x000000011c592e27 -[NSMutableDictionary(NSMutableDictionary) classForCoder] + 0
3 UIKitCore 0x000000013b0e9320 _UIGraphicsBeginImageContextWithOptions + 702
4 ??? 0x0000000180ce3823 0x0 + 6455965731
5 ??? 0x000000017f67b407 0x0 + 6432470023
6 ??? 0x000000017f67acd3 0x0 + 6432468179

Stack trace
  at ObjCRuntime.Runtime.ThrowNSException (System.IntPtr ns_exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.18/src/Xamarin.iOS/ObjCRuntime/Runtime.cs:459
  at ObjCRuntime.Runtime.throw_ns_exception (System.IntPtr exc) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/runtime/Delegates.generated.cs:277
  at at (wrapper native-to-managed) ObjCRuntime.Runtime.throw_ns_exception(intptr)
  at at (wrapper managed-to-native) UIKit.UIGraphics.BeginImageContextWithOptions(CoreGraphics.CGSize,bool,System.nfloat)
  at Xamarin.Forms.Platform.iOS.BrushExtensions.GetBackgroundImage (UIKit.UIView control, Xamarin.Forms.Brush brush) [0x0001d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Extensions\BrushExtensions.cs:116
  at Xamarin.Forms.Platform.iOS.BoxRenderer.SetBackground (Xamarin.Forms.Brush brush) [0x00041] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\BoxRenderer.cs:107
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000d0] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:270
  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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.ScrollViewRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00087] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ScrollViewRenderer.cs:71
  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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.ScrollViewRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00087] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ScrollViewRenderer.cs:71
  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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x0008f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:252
  at at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr)
  at UIKit.UIViewController.get_View () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.18/src/Xamarin.iOS/UIKit/UIViewController.g.cs:2938
  at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:104
  at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0003d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:120
  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.NavigationRenderer.CreateViewControllerForPage (Xamarin.Forms.Page page) [0x00008] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:378
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.OnPushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x0001d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:353
  at at (wrapper managed-to-native) UIKit.UIGraphics.BeginImageContextWithOptions(CoreGraphics.CGSize,bool,System.nfloat)
  at Xamarin.Forms.Platform.iOS.BrushExtensions.GetBackgroundImage (UIKit.UIView control, Xamarin.Forms.Brush brush) [0x0001d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Extensions\BrushExtensions.cs:116
  at Xamarin.Forms.Platform.iOS.BoxRenderer.SetBackground (Xamarin.Forms.Brush brush) [0x00041] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\BoxRenderer.cs:107
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000d0] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:270
  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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.ScrollViewRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00087] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ScrollViewRenderer.cs:71
  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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.ScrollViewRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00087] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ScrollViewRenderer.cs:71
  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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[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:119
  at Xamarin.Forms.Platform.iOS.VisualElementPackager.Load () [0x0001e] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:51
  at Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad () [0x0008f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:252
  at at (wrapper managed-to-native) ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr)
  at UIKit.UIViewController.get_View () [0x0002a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.18/src/Xamarin.iOS/UIKit/UIViewController.g.cs:2938
  at Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:104
  at Xamarin.Forms.Platform.iOS.PageRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x0003d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\PageRenderer.cs:120
  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.NavigationRenderer.CreateViewControllerForPage (Xamarin.Forms.Page page) [0x00008] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:378
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.OnPushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x0001d] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:353
  at Xamarin.Forms.Platform.iOS.NavigationRenderer.<ViewDidLoad>b__47_0 (Xamarin.Forms.Page p) [0x00024] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\NavigationRenderer.cs:239
  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 Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.18/src/Xamarin.iOS/Foundation/NSAction.cs:176
  at at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,intptr,intptr,intptr,intptr&)
  at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.18/src/Xamarin.iOS/UIKit/UIApplication.cs:58
  at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.4.0.18/src/Xamarin.iOS/UIKit/UIApplication.cs:94
  at xx.yy.iOS.Application.Main (System.String[] args) [0x00001] in /Users/u/Documents/development/Xamarin/yy/src/sss/Main.cs:14
@rolfbjarne
Copy link
Member

This looks like a behavioral difference in iOS, which triggers an incorrect/unexpected behavior in Xamarin.Forms.

However, we'll need a test project we can use to reproduce this in order to figure out what's going on.

@AlleSchonWeg
Copy link
Contributor Author

This looks like a behavioral difference in iOS, which triggers an incorrect/unexpected behavior in Xamarin.Forms.

However, we'll need a test project we can use to reproduce this in order to figure out what's going on.

Its difficult, because i don't know what went wrong and what piece of our app triggers the exception. I found devs talking about the same exception in this issue: xamarin/xamarin-macios#18964 (comment)

@rolfbjarne
Copy link
Member

This looks like a behavioral difference in iOS, which triggers an incorrect/unexpected behavior in Xamarin.Forms.
However, we'll need a test project we can use to reproduce this in order to figure out what's going on.

Its difficult, because i don't know what went wrong and what piece of our app triggers the exception. I found devs talking about the same exception in this issue: #18964 (comment)

That doesn't look like the same error:

error UIGraphicsBeginImageContext deprecated when using UIGraphicsContext , use UIGraphicsImageRenderer instead

you're getting:

UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={0, 0}, scale=3.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert.

@AlleSchonWeg
Copy link
Contributor Author

AlleSchonWeg commented Oct 12, 2023

Yes. You are right.
Apple developer forum: https://developer.apple.com/forums/thread/733326

@jonasmayor
Copy link

@rolfbjarne Do you still need a sample to reproduce this?

@rolfbjarne
Copy link
Member

In fact this looks like an issue in Xamarin.Forms, so I'll move it there.

Note that Xamarin.Forms doesn't get many updates anymore, so this is unlikely to be fixed - my suggestion would be to port the app to .NET / MAUI. It may also be possible to modify your project to not run into this scenario, but that's just a wild guess from my side.

@rolfbjarne rolfbjarne transferred this issue from xamarin/xamarin-macios Oct 13, 2023
@jonasmayor
Copy link

In fact this looks like an issue in Xamarin.Forms, so I'll move it there.

Note that Xamarin.Forms doesn't get many updates anymore, so this is unlikely to be fixed - my suggestion would be to port the app to .NET / MAUI. It may also be possible to modify your project to not run into this scenario, but that's just a wild guess from my side.

@rolfbjarne Everytime a ListView or CollectionView controls from Xamarin Forms gets used it blows up with the same exception mentioned above ( and no way around it) I tried every possible way with renderers trying to override all I can by myself but nothing worked. I wish I could migrate to MAUI but last time I tried there were a lot of issues ( like Xamarin on the starts) but I had to switch back to XCode 14.3
Anyway it would be good if Xamarin would get at least another year of support for bugs, not even adding new features while MAUI becomes a more matured product. I've seen in others threads that they the same issue was found for React with the latest IOS 17 and they might have fixed it.

@AlleSchonWeg
Copy link
Contributor Author

Hi,
i tested the whole day to find the problem. I comment my code piece by piece out und tested if the exception still happens.
The exception disappeared as i comment out a custom view. In this view i used a Boxview to draw with a GradientBrush.

Just for testing i replaced the BoxView with a Frame. As a result no exception anymore.

My app contains scrollviews and listviews. But the lists still working. No exceptions.

@jonasmayor
Copy link

jonasmayor commented Oct 16, 2023

I have boxview in mine as well as the separator between items in the collectionView and never occurred to me removing those. When I get a chance I will try that ( I have XCode downgraded to 14.3 version so I will have to update it and try )
@AlleSchonWeg have you seen if the BoxView works outside of any listview/collection view just as a plain border? I guess it won't as then the problem might be the way BoxView get rendered. Wonder also if something could be done on the BoxRenderer in Xamarin

@AlleSchonWeg
Copy link
Contributor Author

I have not tested it without a listview/collectionview/scrollview.
A pr with a fix is already created: #15828
UIGraphics.BeginImageContextWithOptions is used on a few more places:
https://github.com/search?q=repo%3Axamarin%2FXamarin.Forms%20BeginImageContextWithOptions&type=code

@jfversluis There are plans to fix fix the issue?
Thank you

@jfversluis jfversluis added iOS 17 Issues/PRs that are specific to iOS 17/Xcode 15 t/bug 🐛 labels Oct 23, 2023
@JohnHDev

This comment was marked as off-topic.

@AlainHsu

This comment was marked as off-topic.

@datadruid

This comment was marked as off-topic.

@campersau
Copy link
Contributor

The workaround mentioned in #15828 (comment) worked for us. I just needed to adjust it a little bit because we have mainly issues with the BoxView and not the Button.

@damiannestle

This comment was marked as off-topic.

@jfversluis
Copy link
Member

jfversluis commented Nov 3, 2023

@datadruid @AlainHsu @JohnHDev a workaround is available in the linked PR, this should not be blocking you right now.

Let's try and keep this issue focussed on the problem at hand and work towards a solution.

@slprog1
Copy link

slprog1 commented Nov 3, 2023

Got the same error these days, and in my case that was related to setting the linear gradient as background for button.
Reviewing the application build log helped me a lot to find out the reason of this.
The project itself is written in Xamarin.Forms. Definitely, will need to upgrade to .NET MAUI)))

@jfversluis
Copy link
Member

It would still be very helpful to have a reproduction here that shows where this bug hits you to make sure I catch all the places. If you have a minimal sample that shows this behavior, please add it.

@jfversluis
Copy link
Member

Would anyone experiencing this be able to try the NuGets that result from this PR (see instructions here) and let me know if that fixes it for you?

@TheWraithL98
Copy link

Would anyone experiencing this be able to try the NuGets that result from this PR (see instructions here) and let me know if that fixes it for you?

@jfversluis I pulled Xamarin.Forms 5.0.0.8551 from the PR Nuget feed and it fixed my problem - great work! I just found this thread tonight looking into this issue, and great timing as I see the PR happened today. My Xamarin.Forms iOS app which worked fine in iOS 16 and earlier was crashing on iOS 17 devices.

@JohnHDev
Copy link

JohnHDev commented Nov 4, 2023

Would anyone experiencing this be able to try the NuGets that result from this PR (see instructions here) and let me know if that fixes it for you?

@jfversluis I pulled Xamarin.Forms 5.0.0.8551 from the PR Nuget feed and it fixed my problem - great work! I just found this thread tonight looking into this issue, and great timing as I see the PR happened today. My Xamarin.Forms iOS app which worked fine in iOS 16 and earlier was crashing on iOS 17 devices.

to be clear though, its crashing on iOS 17 devices when its built with Xcode 15, right? If built with Xcode 14 you don't see the crash?

@TheWraithL98
Copy link

Would anyone experiencing this be able to try the NuGets that result from this PR (see instructions here) and let me know if that fixes it for you?

@jfversluis I pulled Xamarin.Forms 5.0.0.8551 from the PR Nuget feed and it fixed my problem - great work! I just found this thread tonight looking into this issue, and great timing as I see the PR happened today. My Xamarin.Forms iOS app which worked fine in iOS 16 and earlier was crashing on iOS 17 devices.

to be clear though, its crashing on iOS 17 devices when its built with Xcode 15, right? If built with Xcode 14 you don't see the crash?

In my case, my app seemed to crash on ios17 regardless of build on Xcode 14 or 15. I had several testers move to iOS 17 after it was released and it was bombing on launch even on months old builds.

@jfversluis
Copy link
Member

@JohnHDev are you able to test your scenario?

@JohnHSE
Copy link

JohnHSE commented Nov 6, 2023

@JohnHDev are you able to test your scenario?

Ive asked one of my developers to try it, I hope to have feedback for you today.

@datadruid
Copy link

@rolfbjarne, @jfversluis, @AlainHsu, @JohnHDev I can confirm build 8551 fixes my Xamarin Forms crashing issue for iOS17 simulator with Xcode 15 running Sonoma.

@AlainHsu
Copy link

AlainHsu commented Nov 7, 2023

@rolfbjarne, @jfversluis, @AlainHsu, @JohnHDev I can confirm build 8551 fixes my Xamarin Forms crashing issue for iOS17 simulator with Xcode 15 running Sonoma.

@datadruid Thanks for informing! May I know how you installed build 8551? I'd like to verify that too with Rider IDE.

@jfversluis
Copy link
Member

@AlainHsu instructions are here: https://github.com/xamarin/Xamarin.Forms/wiki/Preview-Packages#pull-requests-

But you'll have to figure out how to add a custom NuGet feed to Rider 😄

@JohnHDev
Copy link

JohnHDev commented Nov 7, 2023

@jfversluis as Devin mentioned its looking good from our perspective. When do you think we'll get the official nuget packages? I can schedule in the upgrade.

@devinAtSchneider
Copy link

@AlainHsu instructions are here: https://github.com/xamarin/Xamarin.Forms/wiki/Preview-Packages#pull-requests-

But you'll have to figure out how to add a custom NuGet feed to Rider 😄

@AlainHsu In Rider, Select NuGet Packages, then select the sources tab and add the PR feed (https://pkgs.dev.azure.com/xamarin/public/_packaging/Xamarin.Forms-PullRequests/nuget/v3/index.json) to your local NuGet.config file, see image below:
Screenshot 2023-11-08 at 08 58 53

@JArmandoCl
Copy link

JArmandoCl commented Feb 26, 2024

Many thanks to @jfversluis I was facing same problem, then found this thread.
I pulled your PR to my app and error is gone, I was able to deploy with no error, in addition:

  1. This kind of buttons throws error (in LinearGradientBrush):
    <Button Command="{Binding Login}" CornerRadius="{OnPlatform Android=30, iOS=20}" FontAttributes="None" FontSize="Medium" HeightRequest="45" HorizontalOptions="Center" Text="INICIAR SESIÓN" TextColor="White" VerticalOptions="Center"> <Button.ImageSource> <FontImageSource FontFamily="fa" Glyph="{x:Static common:DtoIconFont.CircleChevronRight}" Size="Small" Color="White" /> </Button.ImageSource> <Button.Background> <LinearGradientBrush EndPoint="0,1"> <GradientStop Offset="0.15" Color="#E89623" /> <GradientStop Offset="1.0" Color="#BA6c29" /> </LinearGradientBrush> </Button.Background> </Button>

  2. I have an iPhone xs with ios 16.6.1 installed and app works perfectly, but in my personal iPhone 14 PM with ios 17.3.1 the app crashes

  3. To add PR in Visual Studio go to Solution>Nuget Packages>Find the cog located to your right and add a new repo, after that simply switch between repos and download XF 5.0.0.8551.
    image
    image
    image

  4. Test your app

Thanks again @jfversluis

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS 17 Issues/PRs that are specific to iOS 17/Xcode 15 t/bug 🐛
Projects
None yet
Development

Successfully merging a pull request may close this issue.