Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Feb 7, 2020

see also: #8747

The linked PR unintentionally introduced a bug in text range handling where we treated a text range with a location at the end of the string as invalid. This should not be the case.

This resulted in a crash in a11y on iOS when you entered text, the cursor is at the end of the field, and you tap.

This app can reproduce the issue with VoiceOver on:

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'VoiceOver Crash',
      home: Scaffold(
        body: Center(child: TextField()),
      ),
    );
  }
}

Fortunately, the FML change doesn't break any of the original tests - I think it was just an oversight at the time, the other FML method handles cases like this correctly.

/cc @jkurtw @mehmetf @chingjun - this fixes b/149077991

}

TEST(StringRangeSanitizationTest, HandlesEndOfRange) {
EXPECT_EQ(fml::RangeForCharacterAtIndex(@"1234", 4).location, 4UL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add assert for the NSRange.length too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dnfield dnfield merged commit d589dde into flutter:master Feb 7, 2020
@dnfield dnfield deleted the a11y_text_range branch February 7, 2020 20:20
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 7, 2020
Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 8, 2020
dnfield pushed a commit to flutter/flutter that referenced this pull request Feb 8, 2020
* c932214 Ensure fields of Rect and OffsetBase classes are optimized as non-null. (flutter/engine#16465)

* 5c70356 Simplify task queues locking mechanism (flutter/engine#16477)

* d589dde Fix text range logic for a11y (flutter/engine#16496)

* 1a4f4e3 Fix unused import in Android embedder (flutter/engine#16494)

* 964ae10 Disable ShellTest.WaitForFirstFrameTimeout on Fuchsia (flutter/engine#16495)

* 6158f03 Roll src/third_party/skia 87e3bef6f82f..9f3eef796f63 (7 commits) (flutter/engine#16493)
NoamDev pushed a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
Make sure that a text range at the end of the string is still valid.
NoamDev added a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Jan 27, 2025
[Previously approved](flutter/engine#55909) in
/engine before monorepo shift.

Reverts an unnecessary assertion introduced by
[#16496](flutter/engine#16496) that crashes upon
valid user text field interactions. Follow-on work can resolve the
underlying discrepancy between iOS and Flutter range finding (see
#160100). For crash reports, see issue
[#138464](#138464).

## 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], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

Co-authored-by: Chris Bracken <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants