Skip to content

Conversation

@vargajacint
Copy link

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 🙏

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants