Skip to content

Conversation

iBotPeaches
Copy link
Member

@iBotPeaches iBotPeaches commented Sep 29, 2025

This pull request improves the handling and rendering of frozen images in the RNSketchCanvas component, particularly addressing the management of translucent paths and ensuring images are up-to-date before rendering. The changes enhance memory management and prevent potential crashes or rendering issues when working with frozen and translucent images.

Improvements to frozen image management and rendering:

  • Added a new method ensureFrozenImagesUpToDate to make sure that frozen images (_frozenImage and _translucentFrozenImage) are created and current before image rendering operations. This method is now called at the start of createImageWithTransparentBackground. [1] [2]
  • Improved memory management in setFrozenImageNeedsUpdate by only releasing and nullifying _frozenImage and _translucentFrozenImage if they are non-nil, preventing double-releases and potential crashes.

Enhancements to image rendering logic:

  • Updated image drawing logic to check for the existence of _frozenImage and _translucentFrozenImage before drawing them, and only draw _translucentFrozenImage if the current path is translucent. This prevents unnecessary or incorrect image draws. [1] [2]

@iBotPeaches iBotPeaches requested a review from Copilot September 29, 2025 14:58
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request addresses race condition handling for iOS pen input in the sketch canvas by improving frozen image management and preventing potential crashes during image rendering operations.

  • Adds null-safety checks before releasing CGImage references to prevent double-releases
  • Introduces ensureFrozenImagesUpToDate method to guarantee frozen images are current before rendering
  • Updates image drawing logic to conditionally render frozen images based on their existence and path translucency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@iBotPeaches iBotPeaches merged commit a7bd04b into master Sep 30, 2025
1 check passed
@iBotPeaches iBotPeaches deleted the ios-draw-race-condition branch September 30, 2025 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants