gre / react-native-view-shot

Snapshot a React Native view and save it to an image
https://github.com/gre/react-native-view-shot-example
MIT License
2.64k stars 344 forks source link

feat: replaced depricated apis with new ones for ui image #515

Closed vibhor-d11 closed 4 months ago

vibhor-d11 commented 5 months ago

Building with Xcode 15 for iOS 17 lead to the run-time crash when using a deprecated UIGraphicsBeginImageContextWithOptions code on the UIImage instances with .zero size.

Following UI Image apis are depricated from ios 17 when build with Xcode 15:

https://developer.apple.com/documentation/uikit/1623912-uigraphicsbeginimagecontextwitho https://developer.apple.com/documentation/uikit/1623924-uigraphicsgetimagefromcurrentima

Instead need to use UIGraphicsImageRenderer and UIGraphicsImageRendererContext. Have replaced them in this pr.

vibhor-d11 commented 5 months ago

@gre can we merge it?

gre commented 4 months ago

Thanks @vibhor-d11 i've merged it and release it under 4.0.0-alpha.2 so we can test it more. please let me know if everything works for you.

AkashTureha commented 4 months ago

Im getting blank image after adding this PR any reason why is that heppening.

alanjhughes commented 4 months ago

I believe this is a regression. I am also receiving a blank image. Reverting these changes restores the correct behaviour. Note: I have no issues running the previous code on iOS 17

vibhor-d11 commented 4 months ago

I believe this is a regression. I am also receiving a blank image. Reverting these changes restores the correct behaviour. Note: I have no issues running the previous code on iOS 17

Hello @alanjhughes @AkashTureha can you share steps to reproduce for when it is showing blank images? This patch is working fine for us and haven't encountered this issue for our users.

alanjhughes commented 4 months ago

Hi @vibhor-d11 - to reproduce you only need to enable the new architecture.

yasir6jan commented 1 month ago

Hey @alanjhughes What is the version of Xcode you are using for building the app on iOS 17?