flutter icon indicating copy to clipboard operation
flutter copied to clipboard

[Impeller] there is a huge scroll jank when there is a PlatformView and a ListView in a Stack

Open gidrokolbaska opened this issue 1 year ago • 2 comments

Steps to reproduce

  1. Run the code sample;
  2. Scroll the ListView and look at the jank;
  3. Inspect the DevTools to actually see the jank;
  4. Disable the Impeller via info.plist and re-run the app;
  5. Scroll the ListView and there is no jank (you can also see that in DevTools).

It's better on the master channel but still not ideal compared to Skia: image

Code sample

Code sample

https://github.com/gidrokolbaska/platform_view_lag

Performance profiling on master channel

  • [X] The issue still persists on the master channel

Timeline Traces

Timeline Traces JSON

dart_devtools_2024-10-29_18_14_58.205.json.zip

Video demonstration

Video demonstration Without impeller:

https://github.com/user-attachments/assets/d5d06139-848e-4d85-93cc-9aa850fc7ac1

With Impeller:

https://github.com/user-attachments/assets/dc435793-3e89-4d28-a9d4-c6ad3c1bcb22

What target platforms are you seeing this bug on?

iOS

OS/Browser name and version | Device information

iOS 17 simulator

Does the problem occur on emulator/simulator as well as on physical devices?

Yes

Is the problem only reproducible with Impeller?

Yes

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.24.4, on macOS 14.1.2 23B92 darwin-arm64, locale
    ru-RU)
    • Flutter version 3.24.4 on channel stable at
      /Users/gidrokolbaska/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 603104015d (5 days ago), 2024-10-24 08:01:25 -0700
    • Engine revision db49896cf2
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/gidrokolbaska/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /Users/gidrokolbaska/Library/Android/sdk
    • 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.14.3

[✓] 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.94.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.34.0

[✓] Connected device (5 available)
    • iPhoneA (mobile)                • 00008130-00182CE13C06001C            •
      ios            • iOS 17.5.1 21F90
    • iphone 15 pro max (mobile)      • 2628A92D-1113-4F71-9D7C-EF259A4985D5 •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)                 • macos                                •
      darwin-arm64   • macOS 14.1.2 23B92 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                •
      darwin         • macOS 14.1.2 23B92 darwin-arm64
    • Chrome (web)                    • chrome                               •
      web-javascript • Google Chrome 130.0.6723.70

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

• No issues found!

gidrokolbaska avatar Oct 29 '24 15:10 gidrokolbaska

Hi @gidrokolbaska For performance issue, it should be reproduced on a physical device instead of emulator/simulator, please see https://docs.flutter.dev/testing/build-modes#profile.

I checked this on my physical device iPhone 7, iOS 15.8 but couldn't see the issue. Can you also retry on your device iPhoneA and confirm? If the issue also appears there, please let me know what the model of device is.

huycozy avatar Oct 30 '24 08:10 huycozy

Can you also retry on your device iPhoneA and confirm?

on the iPhoneA (which is a iPhone 15 Pro Max) everything seems to be much much better on both stable and master channels. Not ideal but I'm hitting the 120 fps. Here is a screenshot while holding the finger and dragging back and forth (a few janks are still present though): image And here is the screenshot with swipe and release which seems to be better: image

The app has been launched in profile mode on a stable channel. If that's the expected behavior, then we can close the issue, I guess.

gidrokolbaska avatar Oct 30 '24 08:10 gidrokolbaska

My colleague also checked this issue on his device iPhone XS, iOS 18.1 but couldn't see any janks appear as your test.

Demo on iPhone XS, iOS 18.1 (not reproduced)

https://github.com/user-attachments/assets/90eeb096-234f-47aa-823a-5626fdc6692a

Maybe the issue only appears on a high fps device. To investigate the issue further, can you share the updated Timeline Traces JSON when running the app on your device? And it would be helpful if you could check on another device (if you have any) Thanks!

huycozy avatar Oct 31 '24 07:10 huycozy

To investigate the issue further, can you share the updated Timeline Traces JSON when running the app on your device?

Yeah, sure. Here is the zip file with the json data: logs.zip What I've noticed is that the "swipe back and forth while holding the finger" method produces strange metrics when the app is launched in wireless mode via wi-fi and it is much better when connected via cable... The logs are from the stable channel

And it would be helpful if you could check on another device (if you have any)

No, unfortunately. I only have one iPhone at the moment

gidrokolbaska avatar Nov 01 '24 15:11 gidrokolbaska

Thanks for the update. I'm not sure if this is a device-specific issue, I will mark this to get more input from others and update labels later. In the meantime, you can try stripping out webview and replacing with a pure platform views (you can follow iOS docs or use my sample code) to see whether the issue appears or not.

huycozy avatar Nov 04 '24 03:11 huycozy

Re-labled as I don't think this has anything to do with Impeller. Adding iOS team because I'm unsure of the specific touch event behavior.

jonahwilliams avatar Nov 04 '24 18:11 jonahwilliams

I am also not able to reproduce this on a high frame rate 14 Pro.

jonahwilliams avatar Nov 05 '24 19:11 jonahwilliams

We use 2 gesture recognizers ("forwarding" and "delaying" recognizers) to relay the touch to flutter, which could explain some delay of responding to touches. However, it's the same logic for impeller vs non-impeller, so it doesn't explain why this only happens when impeller is enabled

hellohuanlin avatar Nov 06 '24 19:11 hellohuanlin

I don't think there is any evidence that this doesn't happen with skia, except on a simulator which is irrelevant for performance.

jonahwilliams avatar Nov 06 '24 19:11 jonahwilliams

Gave it ago again and on the latest master channel it works flawlessly on physical device connected via cable. No more janks whatsoever

gidrokolbaska avatar Nov 10 '24 15:11 gidrokolbaska

@gidrokolbaska Thanks for checking this again. @jonahwilliams Do you think this is safe to close as fixed or need to track further?

huycozy avatar Nov 12 '24 03:11 huycozy

I could never reproduce it so it was actionable. We can close.

EDit: Wasn't

jonahwilliams avatar Nov 12 '24 03:11 jonahwilliams

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.

github-actions[bot] avatar Nov 26 '24 04:11 github-actions[bot]