fix(flutter): make forceStateUpdate emit state; fix iOS state-listener leak (FR-25944)#141
Closed
dianaKhortiuk-frontegg wants to merge 1 commit into
Closed
fix(flutter): make forceStateUpdate emit state; fix iOS state-listener leak (FR-25944)#141dianaKhortiuk-frontegg wants to merge 1 commit into
dianaKhortiuk-frontegg wants to merge 1 commit into
Conversation
… (FR-25944) forceStateUpdate() never delivered a refreshed state to Flutter, and on iOS it threw MissingPluginException because the method had no handler case. - Android: forceStateUpdate was a comment-only no-op that completed the result without notifying the state listener. Add forceNotifyChanges() to the FronteggStateListener interface and route forceStateUpdate through an extracted, unit-tested top-level forceStateUpdate(listener, result) that calls it. - iOS: add the missing "forceStateUpdate" case and a handler that triggers a one-off state emit via the listener (wired into FronteggMethodCallHandler in register()). - iOS: FronteggStateListenerImpl.subscribe() appended Combine sinks to cancellables without clearing prior ones, so every EventChannel onListen (e.g. hot restart) leaked sinks and fired updateState() once per accumulated sink. Call dispose() at the start of subscribe(). forceNotifyChanges() hops to a background queue before updateState() to avoid the DispatchQueue.main.sync deadlock when invoked from the main-thread method channel. Test: ForceStateUpdateTest (Android, RED->GREEN).
Collaborator
Author
|
Superseded by #142, which combines FR-25941/42/43/44 into a single PR. Branch kept. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FR-25944 — forceStateUpdate broken + iOS listener leak
forceStateUpdate never delivered state
forceStateUpdatewas a comment-only no-op that calledresult.success(null)without ever notifying the state listener. AddedforceNotifyChanges()to theFronteggStateListenerinterface and routedforceStateUpdatethrough an extracted top-levelforceStateUpdate(listener, result)(top-level so it's unit-testable without aContext)."forceStateUpdate"case in the method handler, so it fell through toFlutterMethodNotImplemented→MissingPluginExceptionin Dart. Added the case + a handler that triggers a one-off state emit through the listener, which is now wired intoFronteggMethodCallHandlerinregister().iOS Combine sink leak
FronteggStateListenerImpl.subscribe()appended sinks tocancellableswithout clearing prior ones. EveryEventChannelonListen(e.g. Flutter hot restart / re-listen) leaked the previous subscriptions and firedupdateState()once per accumulated sink. Now callsdispose()at the start ofsubscribe().forceNotifyChanges()dispatches to a background queue beforeupdateState()—sendState()usesDispatchQueue.main.sync, and the force path runs on the main-thread method channel, so a direct call would deadlock. This mirrors how the existing Combine sinks already dispatchupdateState().Tests
ForceStateUpdateTest(Android): with a listener →forceNotifyChanges()fires and the result completes; with no listener → the result still completes. RED → GREEN verified via:frontegg_flutter:testDebugUnitTest.Note
iOS changes pass
swiftc -parseand are consistent with the existing state-listener/threading patterns, but were not compiled in a full iOS build here (no iOS Flutter build harness). Please let CI / an iOS build confirm before merge.