-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
Frame rate is locked to 60FPS on devices with frame rate optimization #35162
Comments
Here are some slow-motion videos of Flutter app and Native app. |
Could it be related to OxygenOS locking some apps to 60fps to save battery? There's a post in XDA that shows how to force 90hz on all apps, could you try a Flutter app after forcing it? |
@ajinasokan can you please use the flutter profiling explained here and post the results. |
@Zazo032 Yes. And Yes. I have mentioned this in the second paragraph. It runs at 90FPS after that. @tottomotto This is not a performance issue. The app is running perfectly fine without janks and frame drops. Problem is that the number of frames is locked to 60 instead of 90. And as I mentioned in the issue, the problem is gone if I force the device to use 90Hz always. So this is something about letting the OS know that Flutter is capable of doing 90FPS. |
There is a commit merged in master which might be connected to this. |
Is this a regression or a new a problem on a new device? If it's the latter, then the referenced commit wouldn't be related. Maybe @chinmaygarde or @jason-simmons have some thoughts on this. |
@tottomotto I tried the master channel. But it doesn't seem to fix the issue. @matthew-carroll This is an issue in One Plus 7 Pro AFAIK. I'm not sure about other Android phones with a higher refresh rate like the Razor phone with 120Hz. |
Sounds a bit like this: #31086 |
@kazenokage I'm not sure about that. That looks more like regression due to the higher sampling rate. Here it is a lock in refresh rate and gets solved by disabling the optimization of One Plus just by changing the config like this:
So this is more like a configuration issue rather than a regression. |
I'm having the same problem. Native apps are running at 90 fps but our Flutter apps are not. |
Having the same problem on my Razer Phone at 120 Hz. Even when scrolling on PageViews, it will appear to be smooth and then stutter near the end of the page-snapping animation. I'd actually argue the app seems more stuttery than on my Pixel 2 locked at 60 Hz. On a possibly-related note, I'm having very conflicting reports of smoothness from users of my app that DON'T appear to be spec-related. Specifically OnePlus and LG owners are complaining that the whole UI has dropped frames. However, on my Pixel 2 (and what most users are saying) it runs incredibly smooth as I would expect, despite the Pixel 2's relatively low specs compared to most OnePlus devices. When setting my Razer Phone to 60 Hz, I get this exact same issue. Super weird! P.S. this seems true for every Flutter app I've tested, including the Flutter gallery. 120 fps appears like 60 and 60 fps appears like 30 with LOTS of random dropped frames. |
How to get the framerate of flutter for desktop app? |
@ping996 You can enable the performance overlay to see if there are any janks. If none then the app is most probably running at the framerate of your display. |
Folks, I have created a thread in One Plus forum. Hopefully, we will get something out of it. If this is some kind of whitelist of package names maintained by One Plus then we are out of luck. And the only solution will be disabling the framerate optimization. |
This isn't just a OnePlus issue. I've got a Xiaomi Redmi K20 Pro with the display overclocked to 75Hz, and it's also running flutter apps at 60Hz. |
@hacker1024 I have changed the title. This issue is so far confirmed in One Plus 7 Pro, Razor phone and Redmi K20 Pro. |
oneplus 7T and 7Tpro also has this issue. |
After executing this command with Oneplus 7T Pro, android studio Frame times window still shows 60FPS This package https://pub.dev/packages/flutter_fps also shows 60FPS On the other hand if you use this app in order to show FPS counter it shows 90FPS everywhere |
Locked to 60 fps with realme X2 Pro (90hz display). I already enabled 90hz mode for the app. |
Has anyone of you tried Pixel 4 to see if Flutter app runs at 90Hz there? I think in my experiments, Pixel 4 runs 90Hz for Flutter apps, but my OnePlus 7 Pro only runs 60Hz for Flutter apps. If you can confirm that, we can once again make the issue title more accurate. And hopefully it can give us some clue of what's going wrong here. |
Do you see 90 FPS in flutter tools in android studio? |
Yes, I've confirmed the results in #35162 (comment) . In summary, there are two issues:
The first issue is probably out of Flutter's control, but we should fix the second one. @devoncarew @kenzieschmoll : can you please take the ownership of that (https://github.com/flutter/flutter/issues/46819)?
After reviewing the comments again, I think this issue #35162 is more about different device manufacturers disabling higher frame rate for Flutter apps by default. Hence I created a new issue https://github.com/flutter/flutter/issues/46819 to track the incorrect frame rate shown by Flutter plugin. @ajinasokan : please keep us posted if you learn something from OnePlus in the bug you filed there. If it's out of Flutter's control, we may have to close the issue here. |
@timsneath I have answered this multiple times in this thread. That workaround is effective. I had mentioned it my original issue itself. But it is not something a normal user can do. Issue now is "frame rate of flutter apps is locked to 60FPS on devices with frame rate optimisation". That workaround is to disable this optimisation. So far developers has reported this in One Plus 7 Pro, One Plus 7T, One Plus 7T Pro, Razer Phone and Xiaomi Redmi K20 Pro. Install flutter gallery app and scroll any list. Now do the same after enabling that workaround. You can feel the difference. Check the videos I posted in this comment to see the difference in slo-mo. If a simple spinning cube OpenGL example can run at 90FPS in my phone then flutter is missing something. |
Great, thanks! I've updated the issue title accordingly. |
Tooling issue incorrectly showing 60 FPS for 90 FPS device was resolved in flutter/flutter-intellij#4289. This will be included in the next plugin release. Fix verified with a Pixel 4. |
When I execute Forcing the app to show |
@kangwang1988 : do you know if and how AliExpress is able to run Flutter at 90 fps without |
@xihuny @liyuqian Alibaba embeds Flutter into their native apps. What you might be looking at could be a native screen and not Flutter. |
I think so too. Take a look at this @liyuqian https://flutter.dev/docs/development/add-to-app |
Maybe One Plus is white listing apps like google chrome, an xda article, see link below, from June 2019 say - "If an app uses SurfaceView, TextureView, or NativeActivity, then the OnePlus 7 Pro will run at 60Hz. However, there are special cases like the Google Chrome browser that uses SurfaceView, but can still be viewed in 90Hz." https://www.xda-developers.com/oneplus-7-pro-true-90hz-display-mode/ |
From the information so far, it seems there's nothing that Flutter engineers can do to unlock the 60+fps on certain devices like OnePlus7 Pro. It's controlled by the hardware manufacturer. I'm closing this issue for now. Please feel free to reopen it if someone finds a way for Flutter to unlock it without hardware manufacturer's involvement. |
We will reach out to the manufacture to be what can be done here. |
We have heard back from One plus, here are their official recommendation:
Description: It should be noted that when the app sets the screen refresh rate, the resolution should not be changed, so you need to use getMode to get the current resolution of the phone as a reference. |
@xster : do you think that we should provide an API in Dart to set the |
Thanks for coordinating @zoeyfan, the summary is helpful. |
@ajinasokan : are you interested in writing such a plugin? Flutter team currently doesn't have a bandwidth to implement it in the short term, but I'm very happy to help reviewing it 😃 |
@ajinasokan : Yes, an external plugin is a better approach. Plugin flutter_windowmanager is a good example. I think all you need is to expose different modes from Display.getSupportedModes() to Dart, let the user choose a |
Folks, I have made a plugin as @liyuqian suggested. Implementation is quite rough. But gets things done in my OnePlus 7 Pro. Check it out in your device and let me know if it works and if I have missed anything. This plugin allows you to choose a specific combination of resolution and frame rate, from a set of modes defined by the device. Here is the repo: ajinasokan/flutter_displaymode |
Thank you @ajinasokan ! Closing this issue. |
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 |
All Flutter apps seem to be locked at 60FPS on One Plus 7 Pro that has 90Hz refresh rate. Every other app including Native apps and OpenGL games runs at 90FPS. Because of this Flutter apps feel slow compared to the rest of the operating system even though there are no performance issues or janks.
It seems apps have to somehow notify the OS that it can do higher framerates. And One Plus OxygenOS seems to do this check and switches between 60 and 90 FPS modes. This XDA article explains how this works and how you can force all apps to use 90FPS. After applying the change mentioned in the article Flutter apps run at 90FPS.
The text was updated successfully, but these errors were encountered: