Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[android] Scrolling is glitchy/jumping with platform views #139734

Closed
@andreasgangso

Description

@andreasgangso

Is there an existing issue for this?

Steps to reproduce

Android specific

  1. Create a scrollable widget (tested with ListView, SingleChildScrollView+Column and PageView)
  2. Put some platform views in there (tested with both initAndroidView and initExpensiveAndroidView)
  3. Scroll slowly

Additional details: IgnorePointer() changes nothing. Also tried with an empty gestureRecognizers and hitTestBehaviorPlatformViewHitTestBehavior.transparent.

Expected results

  1. Normal, smooth scrolling

Actual results

Scroll position is jumping up and down and gets exponentially worse. See video

Code sample

Code sample

See https://github.com/andreasgangso/flutter-platformview-scroll-glitch-bug
Snippet:

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

  @override
  Widget build(BuildContext context) {
    return Stack(children: [
      Scaffold(
        appBar: AppBar(
          title: Text(title),
        ),
        body: SingleChildScrollView(
          child: Column(
            children: <Widget>[
              ...List.generate(
                10,
                (index) => Container(
                  margin: const EdgeInsets.only(bottom: 10),
                  width: double.infinity,
                  height: 500,
                  child: PlatformViewLink(
                    viewType: 'NativeView',
                    surfaceFactory: (context, controller) {
                      return AndroidViewSurface(
                        controller: controller as AndroidViewController,
                        hitTestBehavior: PlatformViewHitTestBehavior.opaque,
                        gestureRecognizers: const <Factory<
                            OneSequenceGestureRecognizer>>{},
                      );
                    },
                    onCreatePlatformView: (params) {
                      var controller = PlatformViewsService.initAndroidView(
                        id: params.id,
                        viewType: 'NativeView',
                        layoutDirection: TextDirection.ltr,
                        onFocus: () {
                          params.onFocusChanged(true);
                        },
                      );
                      controller
                        ..addOnPlatformViewCreatedListener((val) {
                          params.onPlatformViewCreated(val);
                        })
                        ..create();
                      return controller;
                    },
                  ),
                ),
              )
            ],
          ),
        ),
      ),
    ]);
  }
}

Screenshots or Video

Screenshots / Video demonstration
Untitled.mov

Logs

Logs
I/PlatformViewsController(14373): Using hybrid composition for platform view: 0
I/PlatformViewsController(14373): Using hybrid composition for platform view: 1
I/PlatformViewsController(14373): Using hybrid composition for platform view: 2
I/PlatformViewsController(14373): Using hybrid composition for platform view: 3
I/PlatformViewsController(14373): Using hybrid composition for platform view: 4
I/PlatformViewsController(14373): Using hybrid composition for platform view: 5
I/PlatformViewsController(14373): Using hybrid composition for platform view: 6
I/PlatformViewsController(14373): Using hybrid composition for platform view: 7
I/PlatformViewsController(14373): Using hybrid composition for platform view: 8
I/PlatformViewsController(14373): Using hybrid composition for platform view: 9
I/com.example.bu(14373): NativeAlloc concurrent copying GC freed 1454(76KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 1639KB/3279KB, paused 6.550ms total 61.415ms
Reloaded 1 of 700 libraries in 847ms (compile: 11 ms, reload: 354 ms, reassemble: 403 ms).
I/PlatformViewsController(14373): Using hybrid composition for platform view: 10
I/PlatformViewsController(14373): Using hybrid composition for platform view: 11
I/PlatformViewsController(14373): Using hybrid composition for platform view: 12
I/PlatformViewsController(14373): Using hybrid composition for platform view: 13
I/PlatformViewsController(14373): Using hybrid composition for platform view: 14
I/PlatformViewsController(14373): Using hybrid composition for platform view: 15
I/PlatformViewsController(14373): Using hybrid composition for platform view: 16
I/PlatformViewsController(14373): Using hybrid composition for platform view: 17
I/PlatformViewsController(14373): Using hybrid composition for platform view: 18
I/PlatformViewsController(14373): Using hybrid composition for platform view: 19

Flutter Doctor output

Doctor output

Tested on master (3.18.0-7.0.pre.14)
Also tested on: 3.17.0-15.0.pre

Devices tested:
Mi A2 (Android 10 API 29)
SM A515F (mobile) Android 12 (API 31)

[✓] Flutter (Channel master, 3.18.0-7.0.pre.14, on macOS 13.6 22G120 darwin-arm64, locale en-NO)
    • Flutter version 3.18.0-7.0.pre.14 on channel master at /Users/andreasgangso/dev/tools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c22c19b6e2 (14 hours ago), 2023-12-06 15:13:17 -0800
    • Engine revision 347f506a34
    • Dart version 3.3.0 (build 3.3.0-198.0.dev)
    • DevTools version 2.30.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/andreasgangso/Library/Android/sdk
    • Platform android-34, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 2022.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.6+0-17.0.6b802.4-9586694)

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

[✓] VS Code (version 1.85.0-insider)
    • VS Code at /Applications/Visual Studio Code - Insiders.app/Contents
    • Flutter extension version 3.77.20231101

[✓] Connected device (4 available)
    • Mi A2 (mobile)               • 4686c9c                   • android-arm64  • Android 10 (API 29)

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

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    in triagePresently being triaged by the triage teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions