Skip to content

windows: run blocking notification queries on helper isolates - #5

Merged
palmoni5 merged 23 commits into
windows-worker-thread-lazy-libraryfrom
palmoni5/windows-query-helper-isolate-20261108
Nov 9, 2026
Merged

palmoni5 merged 23 commits into
windows-worker-thread-lazy-libraryfrom
palmoni5/windows-query-helper-isolate-20261108

Conversation

@palmoni5

@palmoni5 palmoni5 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Scope (stacked on #4)

Base: palmoni5/fix-windows-notification-memory-integration-20261107@3a30cafe42c917ce8428f4a2667f7dcfbbd92c70. This PR deliberately does not repeat the upstream-compatible new[]/delete[] ownership fix in #4.

The fork's existing C++ NotificationWorker remains the only owner of COM/WinRT calls. The Dart root isolate now uses Isolate.run for the three synchronous FFI waits:

  • getActiveNotifications
  • pendingNotificationRequests
  • updateBindings / native updateNotification

Only sendable primitives (native plugin address, IDs and binding map) cross Dart isolates. Results are copied back as Dart primitives and native arrays are freed in the helper isolate.

Lifetime and native safety

  • Track in-flight helpers; defer native deletion until they finish.
  • Execute native disposePlugin on a helper isolate, as the C++ worker's join can block.
  • Keep the NativeCallable.listener alive until native teardown finishes; bind callbacks to their plugin instance.
  • COM activators share a guarded callback gate; shutdown closes the gate before registration revocation. Retained activators drop and free late notification details without calling a closed Dart callback.
  • Validate GUIDs before allocating a native worker; handle a failed native init.
  • Filter non-numeric/out-of-range Windows toast tags without exceptions escaping the worker. Check malformed native query results before dereferencing.
  • Handle null optional callback maps. Retain new[]/delete[] allocation matching from [windows] fix notification callback string deallocation and add sanitizer coverage #4.

API and ABI compatibility

Public Dart method signatures and the C FFI header src/ffi_api.h are unchanged. Verified header blob SHA on #4 and #5: b2cfe4d7fc427ae93cb3f9519ffb78115a5677de. Internal native lifetime implementation changes only.

QA evidence

  • Windows blocking-FFI responsiveness probe passed using a 650 ms native fixture: 670 ms for the three concurrent queries, 176 timer ticks with a 28 ms maximum UI-isolate gap, plus slow disposal and malformed query arrays.
  • Windows/Linux ownership ASan + UBSan passed. Exercises the production deallocator, malformed map, ID parsing and concurrent callbacks after shutdown.
  • Earlier Windows unit tests and Windows 3.38.1 example build passed after the windows.h max-macro fix; the latest full validate remains subject to final verification.
  • Dart formatter and analyzer pass on the latest branch; the responsiveness probe remains in CI.

Review / merge order

  1. Review [windows] fix notification callback string deallocation and add sanitizer coverage #4 and its ownership tests against windows-worker-thread-lazy-library.
  2. Review this stacked windows: run blocking notification queries on helper isolates #5, then retarget it onto the merged [windows] fix notification callback string deallocation and add sanitizer coverage #4 base if authorized.
  3. Review the matching app consumer #4516 and its pinned SHA; verify Windows builds before merge.

Do not merge any PR without explicit maintainer authorization. The real Windows notification service is not artificially delayed by the fixture; it is covered by the separate native/Windows integration tests rather than the 650 ms synthetic latency benchmark.

palmoni5 commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

QA לאחר תיקון Dart format

בריצה validate #42476672549 ה־Dart formatting checks עבר על ה־HEAD המעודכן 8da0224 (תיקנתי את שני הקבצים לפי diff מדויק מה־formatter).

עברו גם Run Dart Analyzer, Windows unit tests, שני builds של Windows, Linux/macOS/Web builds ובדיקות Dart/Web. Android build על Flutter 3.38.1 עבר. שני כישלונות Android (stable build ו-unit tests) קשורים להורדת Gradle wrapper בסביבת ה-runner; אין במסלולי התיקון הזה קוד Android. iOS integration עדיין בביצוע בזמן בדיקה זו.

אין כאן טענה שכל validate ירוק; PR נשאר Draft. אין לשנות את ה־FFI כדי להסתיר תקלה של download.

palmoni5 commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

אימות לפני Ready: ב־head 8da0224 עברו Dart format, Analyze, Windows unit tests ושתי בניות Windows (Flutter 3.38.1 ו־stable), לצד Linux/macOS/Web ו־Dart unit tests. הכשל בענף Android הוא Gradle download, ולא Windows plugin; iOS integration רץ בנפרד. הבדיקות מכסות dispose עם query בהמתנה, getActive/getPending/update. PR מוכן לסקירת code/FFI ownership; אין למזג אוטומטית ואין לשנות pin של האפליקציה לפני מיזוג/בדיקה מתואמת.

@palmoni5
palmoni5 marked this pull request as ready for review November 8, 2026 12:23
palmoni5 and others added 13 commits November 9, 2026 00:13
…ABI fixture

Add 650ms native blocking query and teardown test, malformed pointer fixtures, strict ID parser tests, and sanitizer coverage for invalid callback maps.
…rt callbacks

Share a guarded callback pointer across retained activation objects; close the gate before COM revocation and test concurrent late callbacks under ASan/UBSan.
…hints

Avoid windows.h max macro conflict in notification ID bounds, retain latency measurements through Zone.current.print without analyzer lints, and normalize package imports.
…review step

Copy exact dart format output from Windows validation job; keep permanent slow-FFI responsiveness regression and sanitizer workflows.

palmoni5 commented Nov 9, 2026

Copy link
Copy Markdown
Member Author

Independent QA checkpoint — Windows notification stack

Reviewed at #5 head faf17437daccb8c74a4d17e6881dc834415de6d8, with base #4 head 3a30cafe42c917ce8428f4a2667f7dcfbbd92c70.

Verified green (exact pinned revision):

Measured on the synthetic slow-DLL harness: three concurrent 650 ms calls finished in approximately 670 ms; 176 UI-isolate timer ticks, maximum observed interval 28 ms. This is not a measurement of an intentionally stalled real Windows notification service.

Disposition: ready for human code review of the stacked diff. Keep the #4 → #5 base relationship until #4 is approved and merged; app #4516 pins this exact #5 SHA and must separately pass consumer Windows CI. No merge was executed or authorized.

createPlugin never returns null (new throws) and native init only queues registration and always returns true, so the failed-init cleanup could not run. Also remove the unused NativeNotificationDetails list helpers, the meaningless INT_MAX check, and fix the instance doc comment that referred to a removed callback.

The query responsiveness workflow now runs on pushes to the integration branch instead of a temporary personal branch pattern.
…ited future

The error surfaced as an unhandled zone error. The callback stays open and calling dispose again retries native teardown.
@palmoni5
palmoni5 changed the base branch from palmoni5/fix-windows-notification-memory-integration-20261107 to windows-worker-thread-lazy-library November 9, 2026 22:34
@palmoni5

palmoni5 commented Nov 9, 2026

Copy link
Copy Markdown
Member Author

QA לפני מיזוג: נוספו dabfb93 (הסרת נתיבי כשל מתים ב-init, helpers לא בשימוש, בדיקת INT_MAX חסרת משמעות, הערת instance שגויה; טריגרי push של ה-workflows עברו לענף המשולב) ו-7cf234c (בלי rethrow מ-future שלא ממתינים לו ב-dispose). מקומית: flutter analyze נקי, flutter test -j 1 – 24/24. CI מלא על 7cf234c (כולל #4) ירוק בפורק האישי: palmoni5#1

@palmoni5
palmoni5 merged commit 6dd532b into windows-worker-thread-lazy-library Nov 9, 2026
25 of 26 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.

1 participant