Skip to content

Conversation

@protikbiswas100
Copy link
Contributor

@protikbiswas100 protikbiswas100 commented Feb 3, 2026

Description

Adding defensive check to ensure device context is valid before D2D operations, this fix protects the RNW layer but does not fix crashes inside RNSVG - that library needs to add its own null checks before calling D2D APIs like SetTextAntialiasMode.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

Prevents crashes from failed BeginDraw: If the drawing surface cannot be acquired, the code now gracefully handles this instead of passing an invalid pointer
Consistent null-safety pattern: External libraries using GetRenderTarget() receive nullptr when the device context is unavailable, allowing them to safely skip drawing
Defense in depth: While the ultimate fix should be in RNSVG itself, these changes provide protection at the React Native Windows boundary

Resolves [https://microsoft.visualstudio.com/OS/_workitems/edit/60739119/?view=edit]

What

Changes made in Autodraw.h and UriImageMangaer.cpp

Screenshots

image

Testing

Tested palyground-composition.sln

Changelog

Should this change be included in the release notes: yes

adding defensive check to ensure device context is valid before D2D operations

@protikbiswas100 protikbiswas100 requested a review from a team as a code owner February 3, 2026 08:52
@protikbiswas100
Copy link
Contributor Author

/azp run PR

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@protikbiswas100 protikbiswas100 merged commit b556619 into main Feb 4, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants