-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IImage Downsize() throws an Exception in 9.0.81 when called from a background thread on iOS. #30426
Copy link
Copy link
Closed
Labels
i/regressionThis issue described a confirmed regression on a currently supported versionThis issue described a confirmed regression on a currently supported versionp/0Current heighest priority issues that we are targeting for a release.Current heighest priority issues that we are targeting for a release.platform/iosregressed-in-9.0.80s/triagedIssue has been reviewedIssue has been reviewedt/bugSomething isn't workingSomething isn't working
Milestone
Description
Description
IImage Downsize() throws an exception in Maui 9.0.81 when called from a background thread on iOS. Note this works in 9.0.71. Also in 9.0.81 the orientation and file size appear to be wrong compared to 9.0.71.
9.0.71
iOS_Maui_9.0.71_video.mp4
9.0.81
iOS_Maui_9.0.81_crash_video_a.mp4
Steps to Reproduce
Sample app demonstrating issue:
https://github.com/brentpbc/maui-camera-settings/tree/main
Use branches to switch between 9.0.81 and 9.0.71 maui versions.
- Select an image using camera or photo picker
- Adjust size/compression sliders to have image reprocessed on a background thread, this will throw an exception on Maui 9.0.81, also file size and orientation appear to be wrong.
See readme for more info.
Link to public reproduction project repository
https://github.com/brentpbc/maui-camera-settings/tree/main
Version with bug
9.0.81 SR8.1
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
9.0.70 SR7
Affected platforms
iOS
Affected platform versions
iOS
Did you find any workaround?
Revert to Maui 9.0.71 or wrap call to IImage.Downsize() in MainThread.InvokeOnMainThreadAsync().
Relevant log output
UIKit.UIKitThreadAccessException: UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread.
at UIKit.UIApplication.EnsureUIThread() in /Users/builder/azdo/_work/1/s/macios/src/UIKit/UIApplication.cs:line 137
at UIKit.UIGraphicsRendererContext.get_CGContext() in /Users/builder/azdo/_work/1/s/macios/src/build/dotnet/ios/generated-sources/UIKit/UIGraphicsRendererContext.g.cs:line 202
at Microsoft.Maui.Graphics.Platform.UIImageExtensions.<>c__DisplayClass1_0.<ScaleImage>b__0(UIGraphicsImageRendererContext imageContext)
at ObjCRuntime.Trampolines.SDActionArity1V263.Invoke(IntPtr block, NativeHandle obj) in /Users/builder/azdo/_work/1/s/macios/src/build/dotnet/ios/generated-sources/ObjCRuntime/Trampolines.g.cs:line 35814
at UIKit.UIGraphicsImageRenderer.CreateImage(Action`1 actions) in /Users/builder/azdo/_work/1/s/macios/src/build/dotnet/ios/generated-sources/UIKit/UIGraphicsImageRenderer.g.cs:line 196
at Microsoft.Maui.Graphics.Platform.UIImageExtensions.ScaleImage(UIImage target, CGSize size, Boolean disposeOriginal)
at Microsoft.Maui.Graphics.Platform.UIImageExtensions.ScaleImage(UIImage target, Single maxWidth, Single maxHeight, Boolean disposeOriginal)
at Microsoft.Maui.Graphics.Platform.PlatformImage.Downsize(Single maxWidth, Single maxHeight, Boolean disposeOriginal)
at MauiCameraSettings.Helpers.ImageHelper.ResizeImageAsync(MemoryStream memStream, String imageType, Int32 resizeValue, Int32 compression, Boolean restoreExifOrientation, Boolean forceMainThread) in /Users/brentparish/src/maui-camera-settings/MauiCameraSettings/MauiCameraSettings/Helpers/ImageHelper.cs:line 74Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
i/regressionThis issue described a confirmed regression on a currently supported versionThis issue described a confirmed regression on a currently supported versionp/0Current heighest priority issues that we are targeting for a release.Current heighest priority issues that we are targeting for a release.platform/iosregressed-in-9.0.80s/triagedIssue has been reviewedIssue has been reviewedt/bugSomething isn't workingSomething isn't working
Type
Projects
Status
Done
