Skip to content

iOS crash: NSInternalInconsistencyException in MessageListTimelineHostCell.preferredLayoutAttributesFitting, invalid row height (1.4.0 (45)) #1043

Closed

Description

@ivanfenenko

Crashlytics issue: 8a645322288c132a10251c0540cd1f46 (iOS, FATAL)
Console: https://console.firebase.google.com/project/opencode-mobile-release/crashlytics/app/ios:dev.opencode.mobile/issues/8a645322288c132a10251c0540cd1f46

Why filed: fatal crash with 1 event on the newest iOS release build, 1.4.0 (45), and no fix merged. Crashlytics flags it SIGNAL_FRESH (first appeared today).

Exception
NSInternalInconsistencyException: Content view returned an invalid size {408, 3617166} from -systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:, which is not allowed.

The content view in the exception is a SwiftUI UIHostingContentView hosting SessionChatTimelineHostRow. At throw time its frame was (0 0; 408 120).

Stack summary (latest event)
Blamed frame: closure #1 in MessageListTimelineHostCell.preferredLayoutAttributesFitting(_:) (MessageListTimelineHostCell.swift:50). That line is fitted = super.preferredLayoutAttributesFitting(attributes), which is when UIKit asks the hosted SwiftUI row to self-size.

NSInternalInconsistencyException: Content view returned an invalid size {408, 3617166} from -systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority: which is not allowed.
  at FIRCLSTerminateHandler()
  at std::__terminate(void (*)())
  at objc_exception_throw
  at -[UICollectionViewCell systemLayoutSizeFittingSize:withHorizontalFittingPriority:verticalFittingPriority:]

Source: ios/OpenCode Mobile/OpenCode Mobile/UI/Scroll/MessageListTimelineHostCell.swift.

Scope (Crashlytics, as of 2026-11-15 16:41 CET)

  • 1 event / 1 user, 2026-11-15 15:18 CET, on 1.4.0 (45) only.
  • Device: iPhone18,2, iOS 27.2.0, app in FOREGROUND.
  • 1.4.0 (45) has 661 reported sessions since 2026-11-11. This is the only crash event on 45 so far.

Root-cause hypothesis
MessageListTimelineHostCell seeds a preferred height from the row-height cache, then calls super.preferredLayoutAttributesFitting. The hosted SessionChatTimelineHostRow returns a width of 408 (plausible) and a height of about 3.6 million points, which UIKit rejects as invalid and turns into an NSInternalInconsistencyException that kills the process.

A height that large usually means a SwiftUI view was measured with no useful height constraint (or at zero width, so text wraps to an enormous column). #1032 fixed a similar “measured at no width, reads far too tall” bug for bottom sheets and is already in 1.4.0 (45), so this looks like a separate residual in the message-list cell self-sizing path, not a recurrence of #1032.

Ideas

  • Clamp the height returned from preferredLayoutAttributesFitting (and/or from the hosting content view) to a sane maximum before UIKit asserts.
  • Find which SessionChatTimelineHostRow content measures this tall (a very long message, a tool result, or a zero-width pass) and give that subtree a width/height constraint during collection-view self-sizing.
  • Avoid caching an invalid height into MessageListTimelineRowHeightCache if a later pass already produced one.

Watch: single event so far, so it may be rare. Will update if the count grows.

Filed by Crashlytics Bot.

Activity

  1. added
    bug
    ios
    priority: high
    crash
    on Nov 15, 2026
  2. ivanfenenko commented on Nov 15, 2026

    @ivanfenenko
    CollaboratorAuthor

    Reproduced, and the fix we agreed on

    Cause. One message is one timeline row, and no message text has a height limit. UIKit rejects a self-sized row taller than about 2,777,777 pt (measured on a 3x simulator) and throws this exception during layout. Text wraps at the correct width; the message simply has too many lines. The zero-width measuring theory from the report was tested and ruled out.

    What triggers it. Line count, not bytes:

    Content Crashes from
    User message, short lines about 147,000 lines (about 290 KB)
    User message, 40-character log lines about 74,000 lines (about 3 MB)
    Assistant text about 121,500 lines
    Code fence about 168,000 lines

    A model cannot write that much in one reply. A user can paste it (a log, a CSV, a file dump), from any client on the same session. The session then crashes the app every time it is opened. A seeded session with a 190,000-line user message reproduced it end to end; a 100,000-line one opened normally.

    Decision.

    • Only the user's own messages are limited. Assistant replies are unchanged.
    • A user message longer than the equivalent of 25 lines is cut in the timeline. The limit is counted from the text in one pass, with no layout measuring: a line break counts as one line and every 40 characters count as one line (so 25 lines is also 1,000 characters). A message only a few lines over is still shown in full.
    • A "Show full message" row sits at the cut, inside the bubble. It opens the whole text in the Select text sheet, where it can be scrolled, selected and copied.
    • Tapping the message still opens the Message sheet, and Copy message copies the whole text.
    • Same behaviour on iOS and Android. The hidden part is never laid out in the timeline.

    Not doing: a cell-level height clamp. With user messages capped nothing realistic reaches the limit, and a clamped row draws wrongly.

  3. added 4 commits that reference this issue on Nov 15, 2026
  4. ivanfenenko commented on Nov 17, 2026

    @ivanfenenko
    CollaboratorAuthor

    Crashlytics triage 2026-11-17: fix PR #1049 (d45629f) merged 2026-11-16 00:14 UTC, not yet in a release build. Issue 8a645322 now shows 2 events / 1 user, all on iOS 1.4.0 (45), iPhone18,2 iOS 27.2.0, last 2026-11-15 14:19 UTC (pre-fix; second event was received late). I'll confirm once a build containing the fix has been out 7+ days with ~50+ sessions and 0 events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcrashiospriority: high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions