[Bug]: iOS connectivity_plus retains callbacks in multi-FlutterEngine apps
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
Direzione di ricerca
Inizia nell’implementazione iOS di connectivity_plus, concentrandoti su ConnectivityPlusPlugin, PathMonitorConnectivityProvider e sul ciclo di vita della registrazione dell’engine. Riproduci il ciclo di creazione, sottoscrizione, distacco e distruzione di più FlutterEngine descritto nell’issue. Il lavoro è completato quando ogni engine rilascia il proprio event sink e il proprio monitor di connettività durante il teardown, i callback non puntano più agli engine distaccati e gli altri engine continuano a monitorare normalmente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Platform
iOS, in applications that register connectivity_plus on more than one FlutterEngine (for example, a long-lived main engine plus short-lived secondary engines).
Plugin
connectivity_plus
Version
7.3.1
Flutter SDK
- Flutter 3.35.7 / Dart 3.9.2: production crash observed in our multi-engine host.
Steps to reproduce
- Create a long-lived FlutterEngine and register
connectivity_plus. - Create a second, short-lived FlutterEngine and register the plugin there too.
- Subscribe to
onConnectivityChangedon the secondary engine. - Destroy or detach the secondary engine while a network callback is pending, then repeat the create/destroy cycle.
Actual behavior
The iOS plugin retains callback chains after an engine is no longer usable:
ConnectivityPlusPlugin -> ConnectivityProvider -> connectivityUpdateHandler -> ConnectivityPlusPluginPathMonitorConnectivityProvider -> NWPathMonitor -> pathUpdateHandler -> PathMonitorConnectivityProvider
The callbacks are assigned as bound method references, which retain their owners. The plugin is also not published through the registrar, so Flutter cannot invoke detachFromEngine(for:) when the engine is deallocated.
In a multi-engine application this leaves stale providers and network callbacks associated with short-lived engines. A later callback can attempt to deliver an EventChannel event after that engine has exited, causing:
Sending a message before the FlutterEngine has been run.
The retained callback graph also prevents timely release of the plugin/provider.
Expected behavior
Each FlutterEngine should own an independent plugin lifecycle. When an engine is detached or deallocated, its connectivity monitor and EventChannel sink should be released without affecting other engines, and no callback should target the detached engine.
Proposed fix
- Use weak captures for both callback edges.
- Publish the plugin instance with
registrar.publish(instance). - Implement
detachFromEngine(for:)to clear the event sink and stop the engine-owned monitor.
This keeps normal connectivity monitoring unchanged while making teardown safe for multi-FlutterEngine hosts.
Code sample
final subscription =
Connectivity().onConnectivityChanged.listen((_) {});
// In a host application, dispose the secondary FlutterEngine while this
// subscription is active, then create another secondary engine.
Logs
Fatal Exception: NSInternalInconsistencyException
Sending a message before the FlutterEngine has been run.
-[FlutterEngine sendOnChannel:message:binaryReply:]
FlutterBinaryMessengerRelay
SetStreamHandlerMessageHandlerOnChannel
SwiftConnectivityPlusPlugin.connectivityUpdateHandler
- Lingua principale
- Dart
- Stelle
- 1.9k
- Fork
- 1.3k
- Merge medio
- 6g 16h
- PR unite (30g)
- 16
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di fluttercommunity/plus_plugins
-
[Bug]: (share_plus) iOS drops the subject when sharing a uriForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
fluttercommunity/plus_plugins#3994 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[package_info_plus]: Use Flutter's compile-time build name/number on web instead of version.jsonForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
fluttercommunity/plus_plugins#3989 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
fluttercommunity/plus_plugins#3976 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
fluttercommunity/plus_plugins#3974 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 48/100
fluttercommunity/plus_plugins#3973 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di fluttercommunity/plus_plugins
Issue simili
-
feat: Order macOS versionsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
quickemu-project/quickgui#328 ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ApplETS/Notre-Dame#1393 ·
-
(fix) Wrong dateAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Solvro/mobile-topwr#1239 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
linagora/twake-on-matrix#3435 ·
I maintainer di solito rispondono entro 3 giorni
-
Regression in v1.6.0: per-error-group update-check notifications flood the notification shadeApertabug to check
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno