Skip to content

Commit 3a44bbe

Browse files
Andrew Hartzlerclaude
andcommitted
Stop filing a framework selection-sort race we cannot fix
Refs FLUTTER-6, FLUTTER-Y. This is a REPORTING change and not a defect fix. Say that plainly: the exception still happens after this ships, we just stop opening a Sentry event for it. Both groups are one defect, split only by the scheduling path that reached it. Verified against the newest event in each and against the framework source at the exact revision production runs, 3.41.8 / 02085feb3f, which this machine has locally. The tail is identical in both: MultiSelectableSelectionContainerDelegate._flushAdditions -> List.sort -> Array.sort -> _compareScreenOrder -> _getBoundingBox -> Selectable.boundingBoxes -> RenderBox.size -> throw StateError box.dart:2303 is `_size ?? (throw StateError('RenderBox was not laid out: ...'))`, so this throws in release where the assert would be stripped. Every frame in both stacks is selectable_region.dart. None is ours. The triage note is right that it is not fixable in our code, and the mechanism is worth writing down because it is not obvious. It is flutter/flutter#151536, open and P2, whose reviewer describes it as selectables from obscured overlay entries that stay registered but are never laid out. That is our shape: an opaque pushed route puts the screen beneath it offstage, _RenderTheatre skips layout for those entries, and a GetX rebuild underneath registers a selectable that has no size when the post-frame flush sorts it. PR #184900 would fix it upstream and is unmerged and contested by the framework reviewer as reactive. There is no code-side avoidance. SelectionContainer.disabled does not penetrate a nested SelectionArea, so gating above the sections does nothing; swapping SelectionArea in and out of the tree changes the widget type at that position and rebuilds every section's subtree, losing scroll and expansion state on every dialog open. Removing SelectionArea costs text selection across the CRM. None of those is a trade worth 9 events in 18 days. The filter is deliberately not keyed on the message. dashboard_screen.dart carries a documented history of real "RenderBox was not laid out" faults of our own, and those must keep reporting. The discriminator is that the throw came out of a JS Array sort comparator, which for this exception can only be the framework: our own comparators sort DashboardWidgetConfig by gridY/gridX, and our four RenderBox.size readers (ballot_row, submission_review_body, section_nav_bar, committee_canvas_tab) are scroll-position and capture helpers with no comparator near them. One implementation note for whoever touches this next. beforeSend runs client side, before upload, so the frames are the raw dart2js stack: fileName is main.dart.js everywhere and the selectable_region.dart names only exist after Sentry applies the source maps server side. The literal "at Array.sort (<anonymous>)" frame survives as an unparsed frame whose `function` carries that text, which is why the predicate reads function and not fileName. Expected rate after this deploys: zero from these two groups. A sighting on dist 72 or later means the discriminator missed and the filter is wrong, not that the framework changed. Build bumped to 72 so the change is measurable in Sentry. Live is still dist 70 across 2525 events in 30d, so 71 never reached production. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SmeS6fuyWAfKxA5NHPMT9w
1 parent f9a80e0 commit 3a44bbe

2 files changed

Lines changed: 50 additions & 1 deletion

File tree

‎lib/main.dart‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,55 @@ Future<void> initSentry() async {
407407
return null;
408408
}
409409

410+
// FLUTTER-6 and FLUTTER-Y: one framework defect under two groups, split
411+
// only by whether the microtask or the frame-callback path reached it.
412+
// Flutter's MultiSelectableSelectionContainerDelegate._flushAdditions
413+
// sorts newly registered selectables with compareOrder, and the
414+
// comparator reads Selectable.boundingBoxes -> RenderBox.size on a
415+
// selectable that was attached but never laid out, which throws
416+
// StateError('RenderBox was not laid out: ...') out of box.dart. Every
417+
// frame in both stacks is selectable_region.dart on 3.41.8; none is
418+
// ours. It is flutter/flutter#151536, open and P2, and the PR that
419+
// would fix it (#184900) is unmerged and contested by the framework
420+
// reviewer as reactive. The selectables come from route content that an
421+
// opaque route above it has pushed offstage: _RenderTheatre skips
422+
// layout for obscured overlay entries, so a rebuild underneath a pushed
423+
// route registers a selectable that has no size when the flush runs.
424+
// We cannot avoid it without either dropping SelectionArea, which costs
425+
// text selection across the CRM, or swapping it in and out of the tree,
426+
// which rebuilds every screen's subtree and loses its state on every
427+
// dialog. So this is a REPORTING change, not a fix: the defect still
428+
// happens, it is non-fatal (the frame's selection update is skipped and
429+
// the app keeps running), and it is not actionable here.
430+
//
431+
// The discriminator is the Array.sort frame, not the message. Sorting
432+
// is the only way our own code could reach this exception without a
433+
// frame of ours on the stack, and nothing we sort reads a RenderBox:
434+
// the dashboard comparators sort DashboardWidgetConfig by gridY/gridX,
435+
// and our four RenderBox.size readers (ballot_row,
436+
// submission_review_body, section_nav_bar, committee_canvas_tab) are
437+
// scroll-position and capture helpers with no comparator anywhere near
438+
// them. Message alone would have been too wide: dashboard_screen.dart
439+
// records a history of real 'RenderBox was not laid out' faults of our
440+
// own, and those must keep reporting.
441+
//
442+
// beforeSend runs before upload, so the frames here are the raw dart2js
443+
// stack: filenames are main.dart.js and the selectable_region.dart
444+
// names only appear after Sentry applies the source maps. The JS
445+
// 'at Array.sort (<anonymous>)' frame survives as an unparsed frame
446+
// whose `function` carries that text, which is why the match is on
447+
// function and not on fileName.
448+
for (final ex in event.exceptions ?? const []) {
449+
if (!(ex.value ?? '').contains('RenderBox was not laid out')) {
450+
continue;
451+
}
452+
final frames = ex.stackTrace?.frames;
453+
if (frames == null) continue;
454+
if (frames.any((f) => (f.function ?? '').contains('Array.sort'))) {
455+
return null;
456+
}
457+
}
458+
410459
return event;
411460
};
412461
});

‎pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description: Send iMessages on Android using BlueBubbles!
1616
# derives `dist` from the build number, so a build shipped without bumping it
1717
# is indistinguishable in Sentry from every build before it. Bump the build
1818
# number whenever a change is meant to be measurable in Sentry.
19-
version: 1.15.0+71
19+
version: 1.15.0+72
2020
publish_to: none
2121

2222
environment:

0 commit comments

Comments
 (0)