From a587e99568015515017de8b05628439e509120f0 Mon Sep 17 00:00:00 2001 From: Tom Brow Date: Fri, 16 Oct 2026 16:25:41 -0700 Subject: [PATCH 1/2] Fix iOS channel crash from unbounded scroll depth (#8407) ### Summary Opening a channel on iOS 27.0.1 could terminate Buzz when a reversed, lazily loaded timeline reported an unbounded scroll extent. Flutter forwarded `Infinity` to the native navigation bar, and UIKit threw `CALayerInvalidGeometry` while setting the scroll view offset. Use the finite viewport depth for that unbounded case, preserving the scrolled-under appearance. Reject non-finite offsets at the native platform boundary as a final safety check. ### Validation - Added tests: a Flutter widget regression for an unbounded reversed timeline, and an iOS native regression for a non-finite platform-channel offset. - Reproduced the original crash by tapping `#general` on an iPhone SE running iOS 27.0.1. With this change, the channel rendered and survived repeated back-and-reopen cycles. Native logging confirmed the channel now sends finite offsets where it previously sent `Infinity`. - The native regression passed on iOS 26.5 and 27.0 simulators with Xcode 27.0. Flutter widget tests and `flutter analyze` passed. - A full channel-flow simulator run was not available: the isolated simulator Profile build could not resolve `BuzzPushKit`. The iOS 27.0.1 physical run exercised the full channel flow. - The full Flutter suite had eight notification and push test failures, all reproduced on the unchanged 0.24.0 source. --------- Signed-off-by: Tom Brow (cherry picked from commit bf8b356f3bf551a01cc24041605ca77d009681dd) --- mobile/ios/Runner/IosNavigationBar.swift | 1 + mobile/ios/RunnerTests/RunnerTests.swift | 23 ++++++++++++++ .../lib/shared/widgets/frosted_scaffold.dart | 10 +++++-- .../shared/widgets/frosted_scaffold_test.dart | 30 +++++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) diff --git a/mobile/ios/Runner/IosNavigationBar.swift b/mobile/ios/Runner/IosNavigationBar.swift index 326df1fb32c..24692e38a3c 100644 --- a/mobile/ios/Runner/IosNavigationBar.swift +++ b/mobile/ios/Runner/IosNavigationBar.swift @@ -530,6 +530,7 @@ private final class IosNavigationBarView: NSObject, FlutterPlatformView { } private func setScrollOffset(_ value: CGFloat) { + guard value.isFinite else { return } offset = max(0, value) material.alpha = alwaysFrosted ? 1 : min(1, offset / 12) applyScroll() diff --git a/mobile/ios/RunnerTests/RunnerTests.swift b/mobile/ios/RunnerTests/RunnerTests.swift index 9dc3eeb6d79..4c11c935a2c 100644 --- a/mobile/ios/RunnerTests/RunnerTests.swift +++ b/mobile/ios/RunnerTests/RunnerTests.swift @@ -520,6 +520,29 @@ class RunnerTests: XCTestCase { } } + @MainActor + func testNavigationIgnoresNonFiniteScrollOffsets() throws { + let parent = UIViewController() + let window = UIWindow(frame: UIScreen.main.bounds) + window.rootViewController = parent + window.makeKeyAndVisible() + defer { window.isHidden = true } + let messenger = NavigationTestMessenger() + let bar = IosNavigationBarFactory(messenger: messenger, parent: parent).create( + withFrame: CGRect(x: 0, y: 0, width: window.bounds.width, height: 120), + viewIdentifier: 999990, + arguments: ["title": "general", "alwaysFrosted": true]) + parent.view.addSubview(bar.view()) + bar.view().layoutIfNeeded() + let navigation = try XCTUnwrap(parent.children.first as? UINavigationController) + let scroll = try XCTUnwrap(navigation.topViewController?.view as? UIScrollView) + messenger.scroll(to: 52) + let finiteOffset = scroll.contentOffset.y + XCTAssertTrue(finiteOffset.isFinite) + messenger.scroll(to: .infinity) + XCTAssertEqual(scroll.contentOffset.y, finiteOffset, accuracy: 0.5) + } + @MainActor func testSubtitlelessThreadKeepsFullFallbackBehindControls() throws { let parent = UIViewController() diff --git a/mobile/lib/shared/widgets/frosted_scaffold.dart b/mobile/lib/shared/widgets/frosted_scaffold.dart index 1c6b2b211fb..1b9f898d36b 100644 --- a/mobile/lib/shared/widgets/frosted_scaffold.dart +++ b/mobile/lib/shared/widgets/frosted_scaffold.dart @@ -175,8 +175,14 @@ class FrostedScaffold extends HookWidget { if (!nativePinned && depth == 0 && metrics.axis == Axis.vertical) { // Keep real depth so a later UIKit metrics update (Dynamic Type or // rotation) can apply its new collapse range without another scroll. - final next = topContentDepth.clamp(0.0, double.infinity); - if ((scrollOffset.value - next).abs() > 0.1) { + // Lazy reversed lists can report an unbounded extentAfter. The + // visible viewport is enough depth for UIKit's collapsed state, + // while infinity is not a valid UIScrollView content offset. + final finiteDepth = topContentDepth.isFinite + ? topContentDepth + : metrics.viewportDimension; + final next = finiteDepth.clamp(0.0, double.infinity); + if (next.isFinite && (scrollOffset.value - next).abs() > 0.1) { WidgetsBinding.instance.addPostFrameCallback((_) { if (context.mounted) scrollOffset.value = next; }); diff --git a/mobile/test/shared/widgets/frosted_scaffold_test.dart b/mobile/test/shared/widgets/frosted_scaffold_test.dart index c77322ff950..6398516843d 100644 --- a/mobile/test/shared/widgets/frosted_scaffold_test.dart +++ b/mobile/test/shared/widgets/frosted_scaffold_test.dart @@ -1,6 +1,7 @@ import 'package:buzz/shared/theme/theme.dart'; import 'package:buzz/shared/widgets/frosted_app_bar.dart'; import 'package:buzz/shared/widgets/frosted_scaffold.dart'; +import 'package:buzz/shared/widgets/ios_navigation_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -12,6 +13,35 @@ Border? _appBarBorder(WidgetTester tester) { } void main() { + testWidgets('unbounded reversed scroll depth stays finite for native bar', ( + tester, + ) async { + await tester.pumpWidget( + const MaterialApp( + home: FrostedScaffold( + appBar: FrostedAppBar(title: Text('Conversation')), + body: SizedBox(key: ValueKey('timeline')), + ), + ), + ); + final source = tester.element(find.byKey(const ValueKey('timeline'))); + final offset = IosNavigationScrollScope.maybeOf(source)!; + ScrollUpdateNotification( + metrics: FixedScrollMetrics( + minScrollExtent: 0, + maxScrollExtent: double.infinity, + pixels: 0, + viewportDimension: 600, + axisDirection: AxisDirection.up, + devicePixelRatio: 1, + ), + context: source, + scrollDelta: 0, + ).dispatch(source); + await tester.pump(); + expect(offset.value, 600); + }); + testWidgets('foreground paints above header and leaves body interactive', ( tester, ) async { From c74495a2f7654a9e0c681a1eadf13b2c0302a27d Mon Sep 17 00:00:00 2001 From: Ross Hartmann Date: Sun, 18 Oct 2026 11:40:21 -0700 Subject: [PATCH 2/2] docs(fork): inventory the upstream iOS channel crash fix cherry-pick (M-4017) Co-Authored-By: Claude Opus 5.5 Signed-off-by: Ross Hartmann --- docs/kiingo-fork-inventory.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/kiingo-fork-inventory.json b/docs/kiingo-fork-inventory.json index 834589b41fe..7a092f90091 100644 --- a/docs/kiingo-fork-inventory.json +++ b/docs/kiingo-fork-inventory.json @@ -1559,6 +1559,19 @@ "purpose": "Typing status phases on mobile: reads the optional {\"v\":1,\"phase\":...} content of kind:20002 typing events and shows the sender's status line (starting up, warming up a session, reconnecting, working, typing); unknown or malformed payloads stay plain typing and \"idle\" ends that sender's typing at once. Typing and the replies that clear it are keyed by the reply e-tag, matching desktop. Kiingo M-4017.", "removalCondition": "Drop when upstream reads typing status phases and scopes mobile typing by the reply tag, or Kiingo agents stop sending phases.", "upstreamStatus": "Generic typing-status extension (backward-compatible content field); not yet submitted to block/buzz." + }, + { + "classification": "drop/upstream-present", + "owner": "Buzz mobile maintainers", + "purpose": "Cherry-pick of upstream block/buzz bf8b356f3 (#8407): opening a channel on iOS 27 terminated the app (CALayerInvalidGeometry) because an unbounded reversed timeline sent Infinity to the native navigation bar. Uses the finite viewport depth and rejects non-finite offsets natively. Shipped ahead of the next sync for Kiingo TestFlight build 4 (M-4017).", + "upstreamStatus": "Upstream-present: block/buzz bf8b356f3 (#8407), landed after snapshot 97e1f6a0.", + "removalCondition": "Drop at the next upstream sync whose snapshot includes block/buzz #8407; these paths then match upstream.", + "paths": [ + "mobile/ios/Runner/IosNavigationBar.swift", + "mobile/ios/RunnerTests/RunnerTests.swift", + "mobile/lib/shared/widgets/frosted_scaffold.dart", + "mobile/test/shared/widgets/frosted_scaffold_test.dart" + ] } ], "budgetAmendments": [