engine icon indicating copy to clipboard operation
engine copied to clipboard

Fix iOS text selection crash by returning nil range

Open importRyan opened this issue 1 year ago • 2 comments
trafficstars

Reverts a runtime crashing assertion introduced by #16496. Defensively favors returning a nil text selection range rather than crash. See issue #138464 for crash reports and reproduction recordings.

Without this revert, to avoid a crash hit in a minority of user interactions with a text field, we must degrade experiences for all users by disabling useful iOS text field behaviors (see #138464 for workarounds).

Pre-launch Checklist

  • [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • [x] I read the Tree Hygiene wiki page, which explains my responsibilities.
  • [x] I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • [x] I listed at least one issue that this PR fixes in the description above.
  • [x] I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • [x] I updated/added relevant documentation (doc comments with ///).
  • [x] I signed the CLA.
  • [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Fix iOS text selection crash by returning nil range

importRyan avatar Oct 16 '24 19:10 importRyan

cc @justinmc

chinmaygarde avatar Oct 21 '24 17:10 chinmaygarde

@chinmaygarde Thanks for that bump. Is there a chance at getting this in the review queue soon?

This assertion is one of our most common crashes. Simply deselecting the text on some touches (this PR) is preferable to tossing the whole app session out.

If there's desire to fix the upstream range finding, that makes sense, but we'd love to save that for focused follow-on where there's a test battery.

importRyan avatar Oct 23 '24 05:10 importRyan

@hellohuanlin can you take a look? My concern is that this regresses https://github.com/flutter/engine/pull/16496 and b/149077991, in which case we need a different solution. https://github.com/flutter/flutter/issues/138464#issuecomment-1912583460

jmagman avatar Oct 28 '24 16:10 jmagman

Honest question: is a regression possible?

Sessions that currently crash will simply now continue, allowing VO/non-VO users to retry input strategies. #16496 stopped a crash when using VoiceOver in a provided sample app. That sample does not crash now.

Thanks for analyzing this and getting it in the queue!

importRyan avatar Oct 30 '24 19:10 importRyan

Should be safe since it's removing NSAssert

@hellohuanlin NSAsserts are on in release mode in Flutter https://github.com/flutter/flutter/issues/157837 (cbracken mentioned he wanted to fix that)

jmagman avatar Nov 04 '24 23:11 jmagman

Formatting issue https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8732309981621212289/+/u/test:_test:_Check_formatting/stdout

jmagman avatar Nov 04 '24 23:11 jmagman

@cbracken @jmagman Are we still making progress on this one?

chinmaygarde avatar Dec 02 '24 18:12 chinmaygarde

Any progress with this one? Customers aren't very happy with crashes

gvozditskiy avatar Dec 11 '24 15:12 gvozditskiy

CI failure is only on mac_android_aot_engine. I don't get a retry option, so I'll push a commit to trigger again.

importRyan avatar Dec 19 '24 02:12 importRyan

Who else would need to approve? Like @gvozditskiy, we'd love to get this crash silenced.

importRyan avatar Dec 30 '24 23:12 importRyan

We just need one more approval thanks. @chunhtai @LongCatIsLooong @cbracken

hellohuanlin avatar Dec 31 '24 06:12 hellohuanlin

auto label is removed for flutter/engine/55909, Failed to merge flutter/engine/55909 with Pull request flutter/engine/55909 could not be merged: You're not authorized to push to this branch. Visit https://docs.github.com/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches for more information..

auto-submit[bot] avatar Jan 10 '25 03:01 auto-submit[bot]

Ah of course, this change needs to be recreated in https://github.com/flutter/flutter/tree/master/engine post-monorepo (this entire repository was moved to that subdirectory).

You can check out https://github.com/flutter/flutter/ and then cd engine/src/flutter. On this branch run git diff main | pbcopy and then in flutter/flutter run pbpaste | patch -p1, then recreate the PR. We'll approve it ASAP given this is already reviewed.

I am also happy to do this, but you'll lose the authorship.

jmagman avatar Jan 10 '25 04:01 jmagman

Monorepo Migration Completed

TL;DR: Please migrate your PR to flutter/flutter

The flutter/engine repository has been migrated to the flutter/flutter repository. This PR will no longer be landed here and must be migrated. To migrate your PR to the flutter repository, please follow these steps:

  1. Create a patch for this PR:

    • Generate a patch set that represents the changes in this PR. The exact method will vary depending on your PR's history. If your PR includes merges, it is highly recommended that you rebase it onto main first.
    git format-patch $START_COMMIT..$END_COMMIT --stdout > combined_patch.patch
    
  2. Update the patch for the new engine location:

    • The engine source code now resides in the engine/ subdirectory within the flutter/flutter repository. You'll need to update the file paths in your patch accordingly.
    # Insert the `engine/` prefix to all paths. Note that this usage works on macOS and
    # linux versions of sed.
    sed -i.bak \
    -e 's|^\(diff --git a/\)\(.*\) b/\(.*\)|\1engine/\2 b/engine/src/flutter/\3|' \
    -e 's|^\(--- a/\)\(.*\)|\1engine/src/flutter/\2|' \
    -e 's|^\(\+\+\+ b/\)\(.*\)|\1engine/src/flutter/\2|' \
    combined_patch.patch
    
  3. Checkout and set up your Flutter development environment:

  4. Set up the engine development environment within the monorepo:

  5. Apply the patch to a new branch:

    • Create a new branch in your flutter/flutter repository.
    • Apply the updated patch to this branch:
    git apply combined_patch.patch
    
  6. Open a new PR:

    • Open a new PR in the flutter/flutter repository with your changes.
    • Reference this original PR in the new PR's description using flutter/engine#<PR_NUMBER>.

This is a canned message

jtmcdole avatar Jan 14 '25 17:01 jtmcdole