Skip to content

Scrollbar gesture recognizers not updated on scroll extent change #150342

Closed

Description

@tgucio

Steps to reproduce

  1. Run flutter create and replace main.dart with the provided code sample.
  2. Run on macOS
  3. Wait a few seconds for the text in the TextField to appear
  4. Do a scroll gesture over the Text using the trackpad
  5. Move the mouse pointer outside of the app window or tap on the app bar
  6. Again, do a scroll gesture over the Text using the trackpad

Expected results

Consistent trackpad scroll behaviour, identical list of gesture recognizers.

Actual results

Inconsistent trackpad scroll behaviour, different list of gesture recognizers.

Before text update:

flutter: Gesture arena 2    ❙ ★ Opening new gesture arena.
flutter: Gesture arena 2    ❙ Adding: VerticalDragGestureRecognizer#8b17a(start behavior: start)
flutter: Gesture arena 2    ❙ Closing with 1 member.
flutter: Gesture arena 2    ❙ Default winner: VerticalDragGestureRecognizer#8b17a(start behavior: start)

After text update:

flutter: Gesture arena 4    ❙ ★ Opening new gesture arena.
flutter: Gesture arena 4    ❙ Adding: VerticalDragGestureRecognizer#8b17a(start behavior: start)
flutter: Gesture arena 4    ❙ Adding: _VerticalThumbDragGestureRecognizer#293c1(debugOwner: _MaterialScrollbarState#10516(tickers: tracking 2 tickers), start behavior: down)
flutter: Gesture arena 4    ❙ Adding: _VerticalThumbDragGestureRecognizer#eacad(debugOwner: _MaterialScrollbarState#1f937(tickers: tracking 2 tickers), start behavior: down)
flutter: Gesture arena 4    ❙ Closing with 3 members.
flutter: Gesture arena 4    ❙ Accepting: _VerticalThumbDragGestureRecognizer#293c1(debugOwner: _MaterialScrollbarState#10516(tickers: tracking 2 tickers), start behavior: down)
flutter: Gesture arena 4    ❙ Self-declared winner: _VerticalThumbDragGestureRecognizer#293c1(debugOwner: _MaterialScrollbarState#10516(tickers: tracking 2 tickers), start behavior: down)

scroll-issue-async

Code sample

Code sample
import 'package:flutter/gestures.dart' show debugPrintGestureArenaDiagnostics;
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final ScrollController _scrollController = ScrollController();
  final TextEditingController _textEditingController = TextEditingController();

  @override
  void initState() {
    super.initState();
    debugPrintGestureArenaDiagnostics = true;

    Future.delayed(const Duration(milliseconds: 3000), () {
      _textEditingController.text =
          'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt '
          'ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco '
          'laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in '
          'voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat '
          'non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n\n' * 10;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          const Text('Wait for it...'),
          Expanded(
            child: Scrollbar(
              controller: _scrollController,
              child: ScrollConfiguration(
                behavior: ScrollConfiguration.of(context).copyWith(
                  scrollbars: false,
                  physics: const BouncingScrollPhysics(),
                ),
                child: TextField(
                  controller: _textEditingController,
                  scrollController: _scrollController,
                  maxLines: null,
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
% flutter doctor -v
[✓] Flutter (Channel master, 3.23.0-13.0.pre.242, on macOS 14.5 23F79 darwin-arm64, locale en-ES)
    • Flutter version 3.23.0-13.0.pre.242 on channel master at /Users/tgucio/Library/Frameworks/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5187cab7bd (2 days ago), 2024-06-14 23:35:34 -0400
    • Engine revision 9779c273aa
    • Dart version 3.5.0 (build 3.5.0-266.0.dev)
    • DevTools version 2.36.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/tgucio/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.90.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.90.0

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 125.0.6422.142

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Activity

  1. tgucio commented on Jun 17, 2024

    @tgucio
    ContributorAuthor

    This appears to happen on scroll extent changes occurring after the initial RawScrollbarState gesture recognizers are created:

      bool _canHandleScrollGestures() {
        return enableGestures
          && _effectiveScrollController != null
          && _effectiveScrollController!.positions.length == 1
          && _effectiveScrollController!.position.hasContentDimensions
          && _effectiveScrollController!.position.maxScrollExtent > 0.0;
      }
    
      Map<Type, GestureRecognizerFactory> get _gestures {
        final Map<Type, GestureRecognizerFactory> gestures = <Type, GestureRecognizerFactory>{};
        if (!_canHandleScrollGestures()) {
          return gestures;
        }

    The _handleScrollNotification method handles maxScrollExtent extent changes only to fade out the scrollbar when there's nothing to scroll, but does not rebuild the widget (which would create new recognisers) when the previously non-scrollable content grows to scrollable.

  2. tgucio commented on Jun 17, 2024

    @tgucio
    ContributorAuthor
  3. danagbemava-nc commented on Jun 17, 2024

    @danagbemava-nc
    Member

    Reproducible using the code sample provided above.

    It appears to work as expected on stable 3.22.2 but the issue appears on master

    Labeling for further investigation

    stable master
    Screen.Recording.2024-06-17.at.11.30.52.mov
    Screen.Recording.2024-06-17.at.11.32.15.mov
    flutter doctor -v
    [!] Flutter (Channel stable, 3.22.2, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
        • Flutter version 3.22.2 on channel stable at /Users/nexus/dev/sdks/flutter
        ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 761747bfc5 (12 days ago), 2024-06-05 22:15:13 +0200
        • Engine revision edd8546116
        • Dart version 3.4.3
        • DevTools version 2.34.3
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.3)
        • Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
        • Build 15E204a
        • CocoaPods version 1.15.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.1)
        • Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 77.2.2
        • Dart plugin version 232.10286
    
    [✓] VS Code (version 1.89.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.90.0
    
    [✓] Connected device (5 available)
        • Nexus (mobile)                  • 00008020-001875E83A38002E • ios            • iOS 17.5.1 21F90
        • Dean’s iPad (mobile)            • 00008103-000825C811E3401E • ios            • iOS 17.5.1 21F90
        • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.4.1 23E224 darwin-arm64
        • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 126.0.6478.62
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    [✓] Flutter (Channel master, 3.23.0-13.0.pre.242, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
        • Flutter version 3.23.0-13.0.pre.242 on channel master at /Users/nexus/dev/sdks/flutters
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 5187cab7bd (2 days ago), 2024-06-14 23:35:34 -0400
        • Engine revision 9779c273aa
        • Dart version 3.5.0 (build 3.5.0-266.0.dev)
        • DevTools version 2.36.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.3)
        • Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
        • Build 15E204a
        • CocoaPods version 1.15.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2024.1)
        • Android Studio at /Users/nexus/Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 77.2.2
        • Dart plugin version 232.10286
    
    [✓] VS Code (version 1.89.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.90.0
    
    [✓] Connected device (5 available)
        • Nexus (mobile)                  • 00008020-001875E83A38002E • ios            • iOS 17.5.1 21F90
        • Dean’s iPad (mobile)            • 00008103-000825C811E3401E • ios            • iOS 17.5.1 21F90
        • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.4.1 23E224 darwin-arm64
        • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 126.0.6478.62
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    
  4. added
    c: regressionIt was better in the past than it is now
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: scrollingViewports, list views, slivers, etc.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Jun 17, 2024
  5. HansMuller commented on Jun 17, 2024

    @HansMuller
    Contributor
  6. HansMuller commented on Jun 21, 2024

    @HansMuller
    Contributor

    Fixed in #150275

  7. added a commit that references this issue on Jun 27, 2024
    e4c18b7
  8. added a commit that references this issue on Jul 8, 2024
    1454550
  9. github-actions commented on Jul 11, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  10. locked as resolved and limited conversation to collaborators on Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: regressionIt was better in the past than it is nowf: scrollingViewports, list views, slivers, etc.found in release: 3.23Found to occur in 3.23frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions