migueldeicaza / SwiftTermApp

MIT License
309 stars 29 forks source link

NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds (TerminalView.updateSelectionAttributesIfNeeded(attributedLine:row:cols:)... #147

Closed instabug[bot] closed 2 years ago

instabug[bot] commented 2 years ago

Title: NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds (TerminalView.updateSelectionAttributesIfNeeded(attributedLine:row:cols:) (AppleTerminalView.swift:458))

Number: 3

Type: Crash

Status: New

Reported At: 2022-04-06 22:14:42 UTC

Email:

Private URL: https://dashboard.instabug.com/applications/swiftterm/beta/crashes/3?utm_source=github&utm_medium=integrations

App Version: 1.0 (135)

Current View: _TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVVS_22_VariadicView_Children7ElementVS_24Navi

Device: iPhone 13 Pro

Duration: 280

User Steps:

22:10:12 Tap in SwiftUI._UIGraphicsView in _TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_24NavigationColumnModifier__
22:10:11 Top View: _TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVS_7AnyViewVS_24NavigationColumnModifier__
22:10:10 Tap in _TtGC7SwiftUI15CellHostingViewGVS_15ModifiedContentVS_14_ViewList_ViewVS_21ListTableCellModifier__ in _TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVVS_22_VariadicView_Children7ElementVS_24NavigationColumnModifier__
22:10:04 Top View: _TtGC7SwiftUI19UIHostingControllerGVS_15ModifiedContentVVS_22_VariadicView_Children7ElementVS_24NavigationColumnModifier__
22:10:04 Tap in _TtCOCV7SwiftUI11DisplayList11ViewUpdater8Platform13CGDrawingView in _TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_
22:09:56 Application: DidBecomeActive
22:09:56 Application: SceneDidActivate
22:09:56 Top View: _TtGC7SwiftUI29PresentationHostingControllerVS_7AnyView_
22:09:56 Application: WillEnterForeground
22:09:56 Application: SceneWillConnect
migueldeicaza commented 2 years ago

I suspect this might be related to the buffer being resized or maybe rotated?

migueldeicaza commented 2 years ago

I scratched my head for a while, until I realized: the selection could be beyond the boundaries of the new size. So the selection had to be invalidated, before the stack recomputes the attributed strings. The attributed strings were created, and then altered based on the selection settings to highlight - but if the selection was using the old values, when the new strings were smaller, it crashed.

In retrospect, I should have seen this