Skip to content

Conversation

@vargajacint
Copy link
Contributor

Description

This PR fixes a crash in ViewScreenshotService occurring on iOS.

The Issue

When screenshotOfViewWithTag: is called on a view that cannot be rendered (e.g. it has a frame of {0,0}, is not currently visible, or the app is in the background), the UIGraphicsImageRenderer may return a valid UIImage object but with a NULL CGImage or empty data.

Attempting to call CGDataProviderCopyData on a null provider, or subsequently CFDataGetLength on a null dataRef, results in a hard crash (typically EXC_BAD_ACCESS or CF_IS_OBJC inside CoreFoundation).

The Fix

Added explicit null checks for:

  1. image.CGImage
  2. The dataRef returned by CGDataProviderCopyData

If either is null, the method now safely returns nullptr, allowing the JS side to handle the failure gracefully, instead of crashing the native runtime.

@wcandillon wcandillon self-requested a review November 28, 2025 08:54
@wcandillon
Copy link
Contributor

Thanks a lot for this 🙏

@wcandillon
Copy link
Contributor

@vargajacint can you sign the CLA please?

@vargajacint
Copy link
Contributor Author

@vargajacint can you sign the CLA please?

@wcandillon Thank you! I believe I did it after the job failed

@wcandillon wcandillon merged commit 5909266 into Shopify:main Nov 28, 2025
16 of 17 checks passed
@github-actions
Copy link
Contributor

🎉 This PR is included in version 2.4.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants