segment_analytics 1.1.11: UI jank / apparent freezes on track
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Bereich
- mobile, performance
Rechercherichtung
Start with lib/utils/store/io.dart and compare the queue persistence and recovery paths between versions 1.1.10 and 1.1.11. Reproduce high-frequency track calls with storageJson enabled, especially from an error interceptor, while observing queue trimming and write-failure behavior. Done means iOS track calls no longer cause disproportionate main-isolate stalls compared with 1.1.10.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
After upgrading segment_analytics from 1.1.10 → 1.1.11, our Flutter app sees severe UI jank / long stalls when Segment track runs on hot paths (e.g. from a Dio onError interceptor). Pinning 1.1.10 removes the problem.
A diff between the two releases shows lib/utils/store/io.dart is essentially the only behavioral change in lib/ between 1.1.10 and 1.1.11, so the regression is very likely tied to the new queue persistence / recovery logic there.
Environment
Package: segment_analytics
Good: 1.1.10
Bad: 1.1.11
Flutter: 3.41.6
Platforms observed: IOS (Iphone 15 IOS version 26.3.2), issue is not there in android
What we’re doing when it happens
Analytics client initialized with default / typical options (storageJson enabled).
High-frequency or latency-sensitive track calls (e.g. after failed HTTP requests from an interceptor).
Symptom: main thread feels blocked; downgrading to 1.1.10 restores smooth behavior with the same app code.
Expected behavior
track should not cause disproportionate main-isolate work compared to 1.1.10: persistence should remain bounded and avoid long CPU + synchronous file I/O bursts during normal operation.
Actual behavior (1.1.11)
Noticeable stalls / jank correlated with Segment persistence; 1.1.10 does not exhibit the same severity.
Analysis (1.1.10 vs 1.1.11)
Comparing lib/utils/store/io.dart between 1.1.10 and 1.1.11:
Per-write overhead for the queue file
1.1.11 adds special handling for the queue file key (queue_flushing_plugin), including building a copy of the queue list and extra json.encode / utf8.encode work on the path to disk — additional cost on every queue persist vs 1.1.10, which used a simpler single-pass write.
Large-queue / large-payload path
When serialized size exceeds _kMaxQueueBytes (~512 KB), 1.1.11 runs trimming (_trimQueueToTargetMap) with repeated full json.encode of the queue — high CPU on the isolate that triggered persistence.
FileSystemException recovery (while (true))
On write failure for the queue file, 1.1.11 enters a loop that re-encodes, re-locks, and re-writes while dropping events until success or empty queue. That can mean many synchronous lockSync / writeFromSync / truncateSync cycles in one persistence operation — a strong candidate for long freezes when disk is stressed or writes fail.
1.1.10 did not implement this recovery/trim loop; it used a straightforward write path.
- Vorherrschende Sprache
- Dart
- Sterne
- 33
- Forks
- 60
- Ø Merge
- 3 T. 16 Std.
- Gemergte PRs (30 T.)
- 7
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus segmentio/analytics_flutter
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
segmentio/analytics_flutter#204 · 1 Reaktion ·
-
[Web] getExistingAnonymousId does not decode JSON-stringified ajs_anonymous_id from localStorageOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
segmentio/analytics_flutter#196 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 50/100
segmentio/analytics_flutter#209 · 1 Kommentar ·
-
the reset not workingOffen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
segmentio/analytics_flutter#187 · 2 Kommentare ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
segmentio/analytics_flutter#186 · 1 Kommentar ·
Alle Issues in segmentio/analytics_flutter
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
firebase/flutterfire#18918 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
customerio/customerio-flutter#441 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
carp-dk/flutter-plugins#1312 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
newrelic/newrelic-flutter-agent#256 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
jhomlala/betterplayer#1646 ·
Maintainer antworten meist innerhalb von 1 Tag