Hi there,
I having just upgraded to the latest Xcode and am testing my app on iOS 15.2. I am receiving the exception `Could not initialize an instance of the type 'CoreGraphics.CGGradient': handle is null.` with the following stack trace:
```
at ObjCRuntime.DisposableObject.InitializeHandle (System.IntPtr handle, System.Boolean verify) [0x00017] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/DisposableObject.cs:80
at ObjCRuntime.DisposableObject..ctor (System.IntPtr handle, System.Boolean owns, System.Boolean verify) [0x00006] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/DisposableObject.cs:51
at CoreFoundation.NativeObject..ctor (System.IntPtr handle, System.Boolean owns, System.Boolean verify) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/CoreFoundation/NativeObject.cs:46
at CoreFoundation.NativeObject..ctor (System.IntPtr handle, System.Boolean owns) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/CoreFoundation/NativeObject.cs:41
at CoreGraphics.CGGradient..ctor (CoreGraphics.CGColorSpace colorspace, CoreGraphics.CGColor[] colors, System.nfloat[] locations) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/CoreGraphics/CGGradient.cs:133
at Syncfusion.iOS.ProgressBar.SfLinearProgressBar.CreateGradient (Syncfusion.iOS.ProgressBar.ProgressBarSegment segment, System.Drawing.RectangleF rect) [0x00342] in <de3640c7a12c4294b5d290566a8561a0>:0
at Syncfusion.iOS.ProgressBar.SfLinearProgressBar.RenderSegment (Syncfusion.iOS.ProgressBar.DrawingContext context, System.Collections.ObjectModel.ObservableCollection`1[T] segments, UIKit.UIColor color, System.Boolean isProgress, System.Boolean canApplyPadding) [0x00054] in <de3640c7a12c4294b5d290566a8561a0>:0
at Syncfusion.iOS.ProgressBar.SfLinearProgressBar.RenderProgressBar (Syncfusion.iOS.ProgressBar.DrawingContext drawing) [0x00038] in <de3640c7a12c4294b5d290566a8561a0>:0
at Syncfusion.iOS.ProgressBar.SfLinearProgressBar.RenderSegment () [0x0004a] in <de3640c7a12c4294b5d290566a8561a0>:0
at Syncfusion.iOS.ProgressBar.ProgressBarBase.Draw (CoreGraphics.CGRect rect) [0x00000] in <de3640c7a12c4294b5d290566a8561a0>:0
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:73
at Foo.iOS.Application.Main (System.String[] args) [0x00000] in C:\Code\Foo\Foo\Foo.iOS\Main.cs:13
```
The issue seems to be caused by SfLinearProgressBar. I am using version 19.4.0.40 of the Syncfusion component.
Hopefully you can help?
Hi Gayathri,
I have created a sample demonstrating the issue here: varyamereon/SfProgressBarIssue (github.com). I am seeing the issue on iOS only, and have tested with the simulator running 15.2 and a device running 15.1. No issue on Android.
Many thanks
Will
Hi Gayathri,
This issue still exists. It can be seen very clearly in the sample project provided. Here is a video of this occuring with the sample project: https://clipchamp.com/watch/OXUMn2o6Ouh.
(The video doesn't show the iOS simulator but the only action taken was to tap the 'increase progress' button once.)
Here is the stack trace:
```
at ObjCRuntime.DisposableObject.InitializeHandle (System.IntPtr handle, System.Boolean verify) [0x00017] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/ObjCRuntime/DisposableObject.cs:81
at ObjCRuntime.DisposableObject..ctor (System.IntPtr handle, System.Boolean owns, System.Boolean verify) [0x00006] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/ObjCRuntime/DisposableObject.cs:51
at CoreFoundation.NativeObject..ctor (System.IntPtr handle, System.Boolean owns, System.Boolean verify) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/CoreFoundation/NativeObject.cs:53
at CoreFoundation.NativeObject..ctor (System.IntPtr handle, System.Boolean owns) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/CoreFoundation/NativeObject.cs:48
at CoreGraphics.CGGradient..ctor (CoreGraphics.CGColorSpace colorspace, CoreGraphics.CGColor[] colors, System.nfloat[] locations) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/CoreGraphics/CGGradient.cs:140
at Syncfusion.iOS.ProgressBar.SfLinearProgressBar.CreateGradient (Syncfusion.iOS.ProgressBar.ProgressBarSegment segment, System.Drawing.RectangleF rect) [0x00342] in <37d56049291946279534231c64dc6475>:0
at Syncfusion.iOS.ProgressBar.SfLinearProgressBar.RenderSegment (Syncfusion.iOS.ProgressBar.DrawingContext context, System.Collections.ObjectModel.ObservableCollection`1[T] segments, UIKit.UIColor color, System.Boolean isProgress, System.Boolean canApplyPadding) [0x00054] in <37d56049291946279534231c64dc6475>:0
at Syncfusion.iOS.ProgressBar.SfLinearProgressBar.RenderProgressBar (Syncfusion.iOS.ProgressBar.DrawingContext drawing) [0x00038] in <37d56049291946279534231c64dc6475>:0
at Syncfusion.iOS.ProgressBar.SfLinearProgressBar.RenderSegment () [0x0004a] in <37d56049291946279534231c64dc6475>:0
at Syncfusion.iOS.ProgressBar.ProgressBarBase.Draw (CoreGraphics.CGRect rect) [0x00000] in <37d56049291946279534231c64dc6475>:0
at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&)
at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/UIKit/UIApplication.cs:57
at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/UIKit/UIApplication.cs:92
at SfProgressBarIssue.iOS.Application.Main (System.String[] args) [0x00001] in C:\Code\SfProgressBarIssue\SfProgressBarIssue\SfProgressBarIssue.iOS\Main.cs:17
```
Hi William,
Currently, we are checking on the issue "SfLinearProgressBar throws CoreGraphics.CGGradient Exception" and
we will update the further details on 27th October 2022.
Regards,
Hemalatha D.
Hi William,
We have analyzed the reported issue and found that the issue is not related to SfProgressBar control, and it’s related to the IOS 15 version. We are using CGGradient to draw a rectangle with radial and axial gradient fills in our control and confirmed that the issue occurred only with iOS 15.2 & above version. Once again, we have reported issue in the Xamarin iOS forum and will let you know once they provide a proper solution to this issue. And we will analyze any possible workaround solution for the issue.
Please find the bug report we created to track the status of this issue,
https://github.com/xamarin/xamarin-macios/issues/16497
Regards,
Hemalatha
D.
Thanks for the update Hemalatha, hopefully looking forward to a fix then.
Will