Skip to content

macOS: Crash in attributedSubstringForProposedRange #153157

@knopp

Description

@knopp

This happens in Sequoia (15.1) with Apple AI enabled.

Stacktrace:

Application Specific Backtrace 0:
0 CoreFoundation 0x00000001984a484c __exceptionPreprocess + 176
1 libobjc.A.dylib 0x0000000197f8ab1c objc_exception_throw + 76
2 CoreFoundation 0x000000019859bab8 -[__NSCFString characterAtIndex:].cold.1 + 0
3 CoreFoundation 0x000000019841e8ec -[NSConstantDictionary objectForKey:] + 0
4 FlutterMacOS 0x0000000107c7b9f8 FlutterMacOS + 195064
5 WritingToolsUI 0x000000026a916630 -[WTAffordanceUIController scheduleShowAffordanceForSelectionRect:ofView:forDelegate:onClick:] + 436
6 WritingToolsUI 0x000000026a90bb70 -[WTWritingTools scheduleShowAffordanceForSelectionRect:ofView:forDelegate:] + 360
7 AppKit 0x000000019c77649c -[NSTextView(NSTextView_WritingTools) updateWritingToolsSelection] + 208
8 AppKit 0x000000019c0b3620 -[NSTextView layout] + 476
9 AppKit 0x000000019cb5fa38 ___NSViewLayout_block_invoke + 632
10 AppKit 0x000000019bfb600c NSPerformVisuallyAtomicChange + 108
11 AppKit 0x000000019bfba87c _NSViewLayout + 96
12 AppKit 0x000000019cb55d30 __36-[NSView _layoutSubtreeWithOldSize:]_block_invoke + 372

The FlutterMacOS frame is at [FlutterTextInputPlugin attributedSubstringForProposedRange:actualRange:]. This happens with custom TextInputPlugin when hiding application and then getting back to it. Hiding application clears the client, which resets the model. When moving application back to foreground macOS requests text at old selection, which now is out of range.

The documentation of attributedSubstringForProposedRange:actualRange specifically says that the implementation must be able to handle range outside of document range.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work lista: desktopRunning on desktopc: crashStack traces logged to the consoleengineflutter/engine related. See also e: labels.fyi-macosFor the attention of macOS platform teamplatform-macBuilding on or for macOS specificallyr: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions