Skip to content

Replace Deprecated BeginImageContextWithOptions with UIGraphicsImageRenderer #18631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

jfversluis
Copy link
Member

Description of Change

In iOS 17 the UIGraphics.BeginImageContextWithOptions API is deprecated and we're using that in a couple of places. This change replaces those with the new thing that we should be using.

Issues Fixed

Related xamarin/Xamarin.Forms#15833 & xamarin/Xamarin.Forms#15827

@jfversluis jfversluis added platform/ios t/housekeeping ♻︎ area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor labels Nov 8, 2023
@jfversluis jfversluis requested a review from a team as a code owner November 8, 2023 15:30
@jfversluis jfversluis marked this pull request as draft November 8, 2023 15:41
@jfversluis
Copy link
Member Author

Converting to draft, the Essentials Screenshot API doesn't work yet

@jfversluis jfversluis marked this pull request as ready for review November 8, 2023 16:07
@rmarinho
Copy link
Member

rmarinho commented Nov 8, 2023

Hum I was going to swear I did this already somewhere

@jfversluis
Copy link
Member Author

This causes some tests to be flaky, not sure how or why...

@jfversluis jfversluis marked this pull request as draft November 9, 2023 12:37
@samhouts samhouts added the stale Indicates a stale issue/pr and will be closed soon label Dec 7, 2023
@dturrina
Copy link

Any news with this? It's some months iOS 17 is out, I'm having the issue for a new implementation but I need to know if something is going to happen at a certain time... or I'll just have to take another way

@vhugogarcia
Copy link
Contributor

Thanks @jfversluis for creating this draft-PR. I also started to face issues on iOS 17.4

024-03-15 10:31:55.496 DemoApp[1221:47820]  Assertion failure in void _UIGraphicsBeginImageContextWithOptions(CGSize, BOOL, CGFloat, BOOL)(), UIGraphics.m:410
 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={0, 820}, scale=2.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert.'

The crash of the app occurs when entering the background on iOS. I tried to merge main to this branch, however, I don't have permissions, so I can test the latest changes. Can somebody give me a hand, please?

@jfversluis jfversluis force-pushed the replace-deprecated-beginimagecontextwithoptions branch from e0ebea1 to ed24f1a Compare March 15, 2024 19:05
@jfversluis
Copy link
Member Author

@vhugogarcia rebased! Is this something you're looking into as well? I'd gladly take some help!

@vhugogarcia
Copy link
Contributor

Hello @jfversluis , I am also looking for an update on this, since I am also facing the issue on my apps. I'm not expert on this topic, I'm totally new. I will try to see what I can do to help to solve the failed tests, maybe we need to update them somehow. Just a guess, hehehe!

@jfversluis
Copy link
Member Author

Oh yeah don't worry was just wondering! 😄 maybe you knew something about it!

@its-jefe
Copy link

Ah man this is so close! I can't find this discussed anywhere else really so I'll just rabble here 😁
This would be significant for iPads running iOS 17 from what I have seen.
App still crashing every time it gets backgrounded.

@jeff-eats-pubsubs
Copy link

👀

@InquisitorJax
Copy link

@jfversluis any word on getting this in?
We're experiencing a crash on iOS when taking photos - tracked down the cause to UIImageExtensions.NormalizeOrientation when doing a File.OpenReadAsync()
image

... this is causing some serious issues in production. Is there any way to work around this?

@jfversluis
Copy link
Member Author

jfversluis commented Mar 28, 2025

This one got stale and I think some calls already got replaced, moving the rest to this updated one: #28682

@jfversluis jfversluis closed this Mar 28, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Apr 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor platform/ios stale Indicates a stale issue/pr and will be closed soon t/housekeeping ♻︎
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants