'Flutter desktop app lags in fullscreen since updating Flutter from 1.26.0-8.0.pre to 2.2.1
I've been working on developing a Flutter Linux desktop app for the past 6 months and decided recently to run flutter upgrade
to update to the latest version. Since doing this, the app performance seems to be the same in small windowed mode, but will become significantly laggier when:
- the window is expanded to take up more of the screen
- the window is maximised
- the application is started in fullscreen mode
I've been cross compiling to run on a raspberry pi with a smaller screen and the same issue occurs - when the window takes up around 30-40% of the screen it performs well, but maximised or full screen causes it to lag.
From the performance overlay, there is no noticeable difference in the UI and Raster threads when in windowed vs fullscreen mode, but the application is much slower.
I'm currently rolling back to previous flutter sdk versions but everything prior to and including 1.26.0-8.0.pre throws the following build error, so I haven't been able to revert to a Flutter version where the fullscreen lagging issue doesn't occur.
[ ] /home/matt/snap/flutter/common/flutter/packages/flutter_tools/bin/tool_backend.sh: line 9:
/home/matt/Developer/switch_prototype/build/linux/release/flutter/"/home/matt/snap/flutter/common/flutter"/bi
n/cache/dart-sdk/bin/dart: No such file or directory
[ ] ninja: build stopped: subcommand failed.
[ +9 ms] Building Linux application... (completed in 97ms)
[ ] "flutter linux" took 366ms.
[ +2 ms] Build process failed
[ +1 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 _runBuild (package:flutter_tools/src/linux/build_linux.dart:145:5)
<asynchronous suspension>
#2 buildLinux (package:flutter_tools/src/linux/build_linux.dart:59:5)
<asynchronous suspension>
#3 BuildLinuxCommand.runCommand (package:flutter_tools/src/commands/build_linux.dart:46:5)
<asynchronous suspension>
#4 FlutterCommand.verifyThenRunCommand
(package:flutter_tools/src/runner/flutter_command.dart:1134:12)
<asynchronous suspension>
#5 FlutterCommand.run.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command.dart:986:27)
<asynchronous suspension>
#6 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#7 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#8 CommandRunner.runCommand (package:args/command_runner.dart:197:13)
<asynchronous suspension>
#9 FlutterCommandRunner.runCommand.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command_runner.dart:274:9)
<asynchronous suspension>
#10 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#11 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#12 FlutterCommandRunner.runCommand
(package:flutter_tools/src/runner/flutter_command_runner.dart:230:5)
<asynchronous suspension>
#13 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:63:9)
<asynchronous suspension>
#14 run.<anonymous closure> (package:flutter_tools/runner.dart:61:12)
<asynchronous suspension>
#15 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#16 AppContext.run (package:flutter_tools/src/base/context.dart:149:12)
<asynchronous suspension>
#17 runInContext (package:flutter_tools/src/context_runner.dart:70:10)
<asynchronous suspension>
#18 main (package:flutter_tools/executable.dart:88:3)
<asynchronous suspension>
[ +2 ms] ensureAnalyticsSent: 0ms
[ +1 ms] Running shutdown hooks
[ ] Shutdown hooks complete
[ ] exiting with code 1
Any help/ideas much appreciated!
Update:
Managed to fix the build error when using older versions of flutter (1.26.0-8.0.pre) to run newer versions of the application (made with 2.2.1).
In linux/flutter/CMakeLists.txt
replacing the following line of code:
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
with
linux-x64 ${CMAKE_BUILD_TYPE}
now allows me to build the application, so now I can build using the old version of flutter but this doesn't fix the lagging issue with new flutter versions.
Solution 1:[1]
I had a similar issue. Even if nothing was happening, in full-screen mode, my MacBook Pro started to get hot, and the fan started to make noise because of the high CPU and GPU usage.
In my case, the main reason was the LinearProgressIndicator
. It is a simple and small animation, but if it runs continuously, it can cost a lot.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Altynbek Usenbekov |