mirror of
https://github.com/electron/electron.git
synced 2026-05-02 03:00:22 -04:00
refactor: use StartUpdating in desktopCapturer Replace the one-shot Update() callback model with the continuous StartUpdating() observer model for NativeDesktopMediaList. Fixes a macOS DCHECK(can_refresh()) crash in UpdateSourceThumbnail(), where ScreenCaptureKit's recurrent thumbnail capturer would post UpdateSourceThumbnail callbacks after the one-shot refresh_callback_ had been consumed. Now, can_refresh() is always true because refresh_callback_ is repopulated via ScheduleNextRefresh(). Each capturer (window, screen) gets its own ListObserver that tracks readiness via OnSourceAdded and OnSourceThumbnailChanged events. Once a list has both sources and thumbnails (or thumbnails aren't requested), its data is snapshotted and the capturer checks if all requested types are ready before resolving to JS. Also remove the "skip_next_refresh_" Chromium patch, which was a workaround for the timing mismatch between the one-shot Update() model and ScreenCaptureKit's asynchronous thumbnail delivery. refactor: simplify state logic in DesktopCapturer