Skip to content

Fix/threading and error handling#7

Open
gmacmaster wants to merge 2 commits into
mainfrom
fix/threading-and-error-handling
Open

Fix/threading and error handling#7
gmacmaster wants to merge 2 commits into
mainfrom
fix/threading-and-error-handling

Conversation

@gmacmaster
Copy link
Copy Markdown

No description provided.

gmacmaster and others added 2 commits April 17, 2026 22:49
m_usingRendering was a plain bool read and written from multiple
dispatcher callbacks (OnTick, PostRenderFrame, StartRendering,
StartDispatcherTimer, StopTicks, createTimerOnQueue) without
synchronization. Changed to std::atomic<bool> to prevent data races.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ndling

The errorInfo shared_ptr was allocated twice in the catch block, with
the first allocation immediately leaked. Removed the duplicate line.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 18, 2026

Greptile Summary

This PR makes two targeted fixes: removes a redundant double-allocation in the wicBitmapSourceFromStream error-handling path in WindowsImageManager.cpp, and promotes m_usingRendering in Timing.h from a plain bool to std::atomic<bool> (adding the required <atomic> include) to prevent a data race when the field is read/written from multiple threads.

Confidence Score: 5/5

Safe to merge — both changes are small, correct, and targeted fixes with no regressions.

No P0 or P1 findings. The duplicate make_shared removal is strictly correct, and the atomic promotion resolves a real data race. No behavioural regressions are introduced.

No files require special attention.

Important Files Changed

Filename Overview
vnext/Microsoft.ReactNative/Fabric/WindowsImageManager.cpp Removes a redundant second std::make_shared() call in the catch block — the first allocation was immediately overwritten, so deleting the duplicate is correct and safe.
vnext/Microsoft.ReactNative/Modules/Timing.h Adds #include and changes m_usingRendering from bool to std::atomic to fix a threading data race; m_usePostForRendering remains a plain bool which may warrant similar treatment depending on its access pattern.

Sequence Diagram

sequenceDiagram
    participant BG as Background Thread
    participant UI as UI Thread
    participant T as Timing struct

    Note over BG,T: Before fix: plain bool, data race
    BG->>T: read m_usingRendering
    UI->>T: write m_usingRendering
    Note over BG,T: UB: concurrent read and write

    Note over BG,T: After fix: atomic bool, race free
    BG->>T: load m_usingRendering (atomic)
    UI->>T: store m_usingRendering (atomic)
    Note over BG,T: Safe: sequential consistency guaranteed
Loading

Reviews (1): Last reviewed commit: "Remove duplicate errorInfo allocation in..." | Re-trigger Greptile

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.

1 participant