Repository navigation
fix(selection): drop stale selection indices after undo, redo and clear (0.3.5) - #56
Merged
Merged
Conversation
Selection, object-eraser and transform state stored positions into the stroke list. Undo/redo/clear/load and object erase rebuilt that list without invalidating them, so Delete after Undo underflowed a size_t in deleteSelection and aborted the app with an uncaught std::length_error, and Delete/Move could act on strokes the user never selected. Reset that state wherever the stroke list is rebuilt, cancel an in-flight transform before reverting, keep reserve() bounded by removed strokes, skip empty undo entries, and hide the iOS selection toolbar after history changes. Adds a native regression smoke test run in CI. Release 0.3.5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
OpenNotes 1.3.2 App Store reviews report crashes "during work" while drawing. This PR reproduces a deterministic crash in the shipped 0.3.4 engine and fixes it.
Selection (
selectedIndices_), the object eraser (pendingDeleteIndices_) and selection transforms store positions intostrokes_. Undo, redo, clear, load and object erase rebuild or compactstrokes_without invalidating those positions.remainingStrokes.reserve(strokes.size() - selectedIndices.size())underflowssize_t,reservethrowsstd::length_error, and the exception reaches the Swift boundary. The result isstd::terminate/ SIGABRT.Fix
SkiaDrawingEngine::resetIndexedSelectionState()drops index-based selection, object-eraser and drag state. It runs whereverstrokes_is rebuilt or compacted: undo, redo, clear, deserialize and object erase.reserve()is bounded by the strokes actually removed, so it cannot underflow.deleteSelectionno longer commits an empty undo entry.onInkSelectionChange. Android already re-emitted this, and it sharescpp/.Evidence
The new
scripts/selection_history_smoke.cpp(npm run test:native:selection-smoke, added to CI andvalidate) has 9 assertions.deleteSelection threw after undo: vector(thelength_error).test:native:smoke,test:native:eraser-smoke, jest (82/82),typecheckandtest:releaseall pass.swiftc -typecheckpasses for the module against the iOS 26.5 simulator SDK and the React prebuilt framework.Release
Bumps the version to 0.3.5 with a CHANGELOG entry. Compared with the published 0.3.4, the only shipped-code change is this fix.