Skip to content

Scrollbar gesture recognizers not updated on scroll extent change #150342

@tgucio

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!

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