Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop app frame rate isn't synced to display #49757

Open
1 of 3 tasks
luigi-rosso opened this issue Jan 30, 2020 · 32 comments · Fixed by flutter/engine#49159
Open
1 of 3 tasks

Desktop app frame rate isn't synced to display #49757

luigi-rosso opened this issue Jan 30, 2020 · 32 comments · Fixed by flutter/engine#49159
Labels
a: desktop Running on desktop c: performance Relates to speed or footprint issues (see "perf:" labels) engine flutter/engine repository. See also e: labels. found in release: 3.19 Found to occur in 3.19 found in release: 3.22 Found to occur in 3.22 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list perf: speed Performance issues related to (mostly rendering) speed platform-linux Building on or for Linux specifically platform-mac Building on or for macOS specifically team-desktop Owned by Desktop platforms team triaged-desktop Triaged by Desktop platforms team

Comments

@luigi-rosso
Copy link

luigi-rosso commented Jan 30, 2020

I'm running on a 120hz monitor, I've scheduled a persistent frame callback and can see that I get ~60fps. It would be great if Flutter could use something like CADisplayLink on MacOS to sync frame rendering with the display.

Gist of a simple app showing this: https://gist.github.com/luigi-rosso/0e3ed273e52764bf1d7bdacca49cccd2

image

I can see in various sites, apps, and games that the display is actually refreshing at 120hz.
image

Previously filed here: google/flutter-desktop-embedding#656

Fix status:

  • Windows
  • macOS
  • Linux
@iapicca iapicca added a: desktop Running on desktop e: glfw GLFW desktop embedding engine flutter/engine repository. See also e: labels. framework flutter/packages/flutter repository. See also f: labels. perf: speed Performance issues related to (mostly rendering) speed c: rendering UI glitches reported at the engine/skia rendering level platform-mac Building on or for macOS specifically labels Jan 30, 2020
@stuartmorgan stuartmorgan removed e: glfw GLFW desktop embedding c: rendering UI glitches reported at the engine/skia rendering level labels Jan 30, 2020
@goderbauer goderbauer removed the framework flutter/packages/flutter repository. See also f: labels. label Jan 30, 2020
@liyuqian liyuqian added the c: performance Relates to speed or footprint issues (see "perf:" labels) label Mar 30, 2020
@stuartmorgan stuartmorgan added the P3 Issues that are less important to the Flutter project label Jun 10, 2020
@TahaTesser
Copy link
Member

TahaTesser commented Nov 5, 2020

This is not just mac, I can also see it's 60 fps on Windows even tho my laptop is 144hz. It would be across all desktop apps

image
image (1)

flutter doctor -v
[✓] Flutter (Channel master, 1.24.0-8.0.pre.97, on Microsoft Windows [Version 10.0.19042.610], locale en-US)
    • Flutter version 1.24.0-8.0.pre.97 at C:\Code\flutter_master
    • Framework revision 4c24eb10b8 (57 minutes ago), 2020-11-05 11:18:00 +0100
    • Engine revision e66a720137
    • Dart version 2.12.0 (build 2.12.0-21.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Code\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Code\android-studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.
[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.7.30621.155
    • Windows 10 SDK version 10.0.18362.0
[✓] Android Studio (version 4.1.0)
    • Android Studio at C:\Code\android-studio
    • 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 1.8.0_242-release-1644-b01)
[✓] VS Code (version 1.50.1)
    • VS Code at C:\Users\taha\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.16.0
[✓] Connected device (5 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.19042.610]
    • Web Server (web)        • web-server    • web-javascript • Flutter Tools
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 86.0.4240.183
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 86.0.622.61
• No issues found!

@TahaTesser TahaTesser added platform-linux Building on or for Linux specifically platform-windows Building on or for Windows specifically labels Nov 5, 2020
@TahaTesser TahaTesser changed the title MacOS frame rate isn't synced to display Desktop app frame rate isn't synced to display Nov 5, 2020
@TahaTesser TahaTesser added found in release: 1.24 Found to occur in 1.24 has reproducible steps The issue has been confirmed reproducible and is ready to work on passed first triage labels Nov 5, 2020
@csells
Copy link
Contributor

csells commented Nov 16, 2020

@stuartmorgan thoughts?

@TahaTesser
Copy link
Member

TahaTesser commented Nov 20, 2020

@csells
For mobile, looks like this is the approach #35162 (comment) and the issue was closed by a team member due to the presence of a third-party package to mitigate this issue

I would think @stuartmorgan might do the same for desktop, add a new plugin in https://github.com/google/flutter-desktop-embedding/tree/master/plugins or add higher frame rate sync ability in an existing plugin. Feel free to correct me

Personally, I would love to see this support in the framework without depending on a third-party/first-party package for all platforms that Flutter supports. Most devices are higher rate now

@iBob101
Copy link

iBob101 commented Dec 27, 2020

@gardc

This comment was marked as off-topic.

@jmagman
Copy link
Member

jmagman commented Oct 25, 2021

See also #90675

@iWonAMathsDebate
Copy link

iWonAMathsDebate commented Nov 12, 2021

Is there any ETA on this issue @stuartmorgan ? This is the only reason I'm not using Flutter for my gaming oriented desktop app

@stuartmorgan stuartmorgan removed the P3 Issues that are less important to the Flutter project label Nov 12, 2021
@Sakari369
Copy link

Tested on the macOS desktop target yesterday, and the frametimes were around 8.3 ms, and renders at 120 FPS so I guess this now works on the master branch as of currently, so probably this issue is also fixed ?

@lesnitsky
Copy link
Contributor

I'm testing it currently on the master channel and I see the framerate locked at 60fps.

The same app built for ios with "Designed for iPad", so it could be run on arm mac shows 120fps and the difference is very noticeable while scrolling

@lesnitsky
Copy link
Contributor

what is the usual timeline for the latest engine to be rolled into the flutter dev channel?

@nortio
Copy link

nortio commented Feb 28, 2024

Linux desktop still has this issue as of today

edit: tested on engine d068d980f9525bdfa0224067c01171c24bb39d66 with GNOME 45 on Wayland with a 144hz monitor:

Screenshot from 2024-02-29 10-32-28

Will test on X11 soon

@nortio
Copy link

nortio commented Feb 29, 2024

on engine d068d980f9525bdfa0224067c01171c24bb39d66 with XFCE (X11) with a 144hz monitor:

x11

@nortio
Copy link

nortio commented Mar 5, 2024

If needed, I can test on more distributions. The tests above were done in a Debian 12 environment (container hosted on NixOS) with flutter channel master. I can test on less exotic setups but it shouldn't matter since the container has access to the same Wayland and X server as other apps. In fact, I also tested this a while back on an Ubuntu 22.04 machine connected to the same monitor and the issue was still there. Let me know if you want to replicate it again.

@loic-sharma
Copy link
Member

@knopp FYI, it looks like FlutterVSyncWaiterTest.VSyncWorks is flaky:

[ RUN      ] FlutterVSyncWaiterTest.VSyncWorks
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
../../flutter/shell/platform/darwin/macos/framework/Source/FlutterVSyncWaiterTest.mm:171: Failure
Value of: displayLink.paused
  Actual: false
Expected: true

[  FAILED  ] FlutterVSyncWaiterTest.VSyncWorks (134 ms)

Example failure: https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20Production%20Engine%20Drone/288087/overview

@knopp
Copy link
Member

knopp commented Mar 14, 2024

@knopp FYI, it looks like FlutterVSyncWaiterTest.VSyncWorks is flaky:

[ RUN      ] FlutterVSyncWaiterTest.VSyncWorks
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
[WARNING:flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.mm(77)] Communicating on a dead channel.
../../flutter/shell/platform/darwin/macos/framework/Source/FlutterVSyncWaiterTest.mm:171: Failure
Value of: displayLink.paused
  Actual: false
Expected: true

[  FAILED  ] FlutterVSyncWaiterTest.VSyncWorks (134 ms)

Example failure: https://ci.chromium.org/ui/p/flutter/builders/prod/Mac%20Production%20Engine%20Drone/288087/overview

I think the tolerances there are too tight for the runner. I'll make a PR soon.

@knopp
Copy link
Member

knopp commented Mar 14, 2024

@loic-sharma flutter/engine#51405

@mit-mit
Copy link
Member

mit-mit commented Apr 3, 2024

@cbracken is this still an issue after we landed the engine fix?

@knopp
Copy link
Member

knopp commented Apr 3, 2024

@cbracken is this still an issue after we landed the engine fix?

It is fixed on macOS, but I believe while windows has the correct period the phase might be off. And I think linux might be running on fallback 60hz always? Edit: I think qpcVBlank from DWM_TIMING_INFO could be used to determine vsync phase, but the embedder is not using it right now.

@mit-mit
Copy link
Member

mit-mit commented Apr 3, 2024

I thought Windows was resolved based on the comments in #49757 (comment) and just below that.

@knopp
Copy link
Member

knopp commented Apr 3, 2024

I thought Windows was resolved based on the comments in #49757 (comment) and just below that.

That PR did resolve the framerate interval (period), but I don't think it solved the phase, i.e. the vsync timer is fired correct amount of times per second, but the relative position within vsync period might be wrong.

@huycozy
Copy link
Member

huycozy commented Apr 26, 2024

On my Linux machine with 75 Hz monitor, but I see it's 60 FPS on Flutter app. Not sure if it's intended or not (based on Knopp's comment above), I'm updating labels for further investigation.

flutter doctor -v (stable & master)
[✓] Flutter (Channel stable, 3.19.6, on Ubuntu 22.04.3 LTS 6.5.0-26-generic, locale en_US.UTF-8)
    • Flutter version 3.19.6 on channel stable at /home/huynq/Documents/Working/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 54e66469a9 (2 days ago), 2024-04-17 13:08:03 -0700
    • Engine revision c4cd48e186
    • Dart version 3.3.4
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc3)
    • Android SDK at /home/huynq/Android/Sdk/
    • Platform android-33, build-tools 34.0.0-rc3
    • Java binary at: /snap/android-studio/current/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1.1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2021.1)
    • Android Studio at /home/huynq/Documents/android-studio
    • Flutter plugin version 67.0.1
    • Dart plugin version 211.7817
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[!] Android Studio (version unknown)
    • Android Studio at /snap/android-studio/current
    • 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
    ✗ Unable to determine Android Studio version.
    • android-studio-dir = /snap/android-studio/current
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.84.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.86.0

[✓] VS Code (version 1.88.1)
    • VS Code at /snap/code/current/usr/share/code
    • Flutter extension version 3.86.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.04.3 LTS 6.5.0-26-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 120.0.6099.199

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

! Doctor found issues in 1 category.
[!] Flutter (Channel master, 3.22.0-14.0.pre.35, on Ubuntu 22.04.3 LTS 6.5.0-26-generic, locale en_US.UTF-8)
    • Flutter version 3.22.0-14.0.pre.35 on channel master at /home/huynq/Documents/Working/flutter_master
    ! Warning: `flutter` on your path resolves to /home/huynq/Documents/Working/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /home/huynq/Documents/Working/flutter_master. Consider adding /home/huynq/Documents/Working/flutter_master/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /home/huynq/Documents/Working/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /home/huynq/Documents/Working/flutter_master. Consider adding /home/huynq/Documents/Working/flutter_master/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9feccd5f3b (2 hours ago), 2024-04-19 05:08:40 -0400
    • Engine revision 4ed7a2d6ae
    • Dart version 3.5.0 (build 3.5.0-77.0.dev)
    • DevTools version 2.35.0-dev.8
    • 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-rc3)
    • Android SDK at /home/huynq/Android/Sdk/
    • Platform android-33, build-tools 34.0.0-rc3
    • Java binary at: /snap/android-studio/current/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • Ubuntu clang version 14.0.0-1ubuntu1.1
    • cmake version 3.22.1
    • ninja version 1.10.1
    • pkg-config version 0.29.2

[✓] Android Studio (version 2021.1)
    • Android Studio at /home/huynq/Documents/android-studio
    • Flutter plugin version 67.0.1
    • Dart plugin version 211.7817
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[!] Android Studio (version unknown)
    • Android Studio at /snap/android-studio/current
    • 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
    ✗ Unable to determine Android Studio version.
    • android-studio-dir = /snap/android-studio/current
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.84.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.86.0

[✓] VS Code (version 1.88.1)
    • VS Code at /snap/code/current/usr/share/code
    • Flutter extension version 3.86.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 22.04.3 LTS 6.5.0-26-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 120.0.6099.199

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

! Doctor found issues in 2 categories.

@huycozy huycozy added found in release: 3.19 Found to occur in 3.19 found in release: 3.22 Found to occur in 3.22 and removed found in release: 1.24 Found to occur in 1.24 labels Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: desktop Running on desktop c: performance Relates to speed or footprint issues (see "perf:" labels) engine flutter/engine repository. See also e: labels. found in release: 3.19 Found to occur in 3.19 found in release: 3.22 Found to occur in 3.22 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list perf: speed Performance issues related to (mostly rendering) speed platform-linux Building on or for Linux specifically platform-mac Building on or for macOS specifically team-desktop Owned by Desktop platforms team triaged-desktop Triaged by Desktop platforms team
Projects
None yet
Development

Successfully merging a pull request may close this issue.