Skip to content

Commit 10a4136

Browse files
committed
fix(linux): let the Flutter 3.50.0 engine blit on NVIDIA
Flutter 3.50.0's Linux engine draws each frame half a window down and to the left when it composites without glBlitFramebuffer (flutter/flutter#195885): the UI sat in the bottom-left quarter of the window, the rest was black, and taps missed. The engine blocklists every NVIDIA driver for glBlitFramebuffer, so all NVIDIA proprietary drivers hit that path, on Hyprland, GNOME and X11 alike. At install, linux/flutter_3_50_0_fix.cmake renames that blocklist entry in the bundle's copy of the engine (same length, matched and re-checked by SHA-256 for 3.50.0 debug, profile and release), so NVIDIA blits like Intel and AMD. The SDK's copy and other engine versions are left alone. Correcting the fallback's shader offset instead, as the upstream fix for 3.50.1 does, was still off at a fractional scale (133 % on GNOME). Checked on an RTX 5060 with driver 615.78.08, GNOME on Wayland at 133 %. CONTRIBUTION.md says when and how to remove the patch.
1 parent 5d479f0 commit 10a4136

3 files changed

Lines changed: 60 additions & 0 deletions

File tree

‎docs/CONTRIBUTION.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ bash linux/packaging/build-rpm.sh # version defaults to pubspec.yaml
8989

9090
The RPM is written to `dist/`. Before packaging, the script checks that the bundled QuickJS library loads and exports the functions used by source extensions; CI runs the same check before creating the AppImage. It installs the Flutter bundle under `/opt/yoru`, a `/usr/bin/yoru` launcher, and the desktop entry and icon. Install or update it with `sudo dnf install ./dist/Yoru-<version>-linux-x86_64.rpm`.
9191

92+
**Flutter 3.50.0 engine patch (temporary).** Flutter 3.50.0's Linux engine draws each frame half a window down and to the left on NVIDIA's proprietary driver: the UI sits in the bottom-left quarter, the rest is black, and taps miss ([flutter#195885](https://github.com/flutter/flutter/issues/195885)). The engine blocklists NVIDIA for `glBlitFramebuffer`, and its fallback path has the offset bug. `linux/flutter_3_50_0_fix.cmake`, run from `linux/CMakeLists.txt` at install, renames that blocklist entry in the bundle's copy of the engine (`lib/libflutter_linux_gtk.so`, same length, matched and re-checked by SHA-256 for 3.50.0 debug, profile and release), so NVIDIA blits like Intel and AMD; the SDK's copy is untouched, and any other engine version is left alone. Every Linux build, AppImage and RPM included, gets it; a hash mismatch fails the build. Correcting the fallback's shader offset instead (as the upstream fix, [flutter#196083](https://github.com/flutter/flutter/pull/196083), does) is still off at fractional scales such as 133 % on GNOME or Hyprland. Checked on an RTX 5060, driver 615.78.08, GNOME on Wayland at 133 %. **When moving to Flutter 3.50.1 or later:** run the app on NVIDIA at a fractional scale first; if it fills the window, delete the cmake file and its block in `linux/CMakeLists.txt`.
93+
9294
RPM installs also support in-app updates: the app requires a SHA-256 digest from the release asset, downloads and verifies the RPM, and runs DNF through polkit's administrator prompt. A missing digest refuses the update before download or administrator approval. It restarts as the desktop user only after DNF succeeds; cancelling approval or a failed transaction leaves the app open. In-app updates need DNF, pkexec, and a running desktop authentication agent; DNF and pkexec are recommended dependencies so the RPM can still be installed without them. WebKitGTK 4.1 is also recommended for the in-app WebView. Bundled libraries stay private to Yoru in the RPM dependency metadata.
9395

9496
RPM update checks use the same upstream releases (`sofyan-rs/yoru-comic-app`) as the other platforms. Publish a newer version with a `-linux-x86_64.rpm` release asset for RPM clients to find it. There is no fallback to AppImage when a release lacks the RPM.

‎linux/CMakeLists.txt‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}
100100
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
101101
COMPONENT Runtime)
102102

103+
# Flutter 3.50.0's engine draws the app half a window off on NVIDIA's driver
104+
# (flutter/flutter#195885): the bundle's copy blits there until Flutter 3.50.1.
105+
get_filename_component(FLUTTER_LIBRARY_NAME "${FLUTTER_LIBRARY}" NAME)
106+
install(CODE "
107+
include(\"${CMAKE_CURRENT_SOURCE_DIR}/flutter_3_50_0_fix.cmake\")
108+
fix_flutter_3_50_0_engine(\"${INSTALL_BUNDLE_LIB_DIR}/${FLUTTER_LIBRARY_NAME}\")
109+
" COMPONENT Runtime)
110+
103111
foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES})
104112
install(FILES "${bundled_library}"
105113
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"

‎linux/flutter_3_50_0_fix.cmake‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Flutter 3.50.0's Linux engine draws each frame half a window down and to the
2+
# left when it composites without glBlitFramebuffer: the app shows in the
3+
# bottom-left quarter of its window, the rest is black, and taps land where
4+
# the hidden layout is. https://github.com/flutter/flutter/issues/195885,
5+
# fixed upstream in https://github.com/flutter/flutter/pull/196083 for 3.50.1.
6+
#
7+
# The engine skips glBlitFramebuffer for drivers whose GL vendor contains
8+
# "NVIDIA" (a 2024 blocklist, https://github.com/flutter/flutter/issues/152099),
9+
# so every NVIDIA proprietary driver hits that broken path. Correcting the
10+
# path's offset in its shader isn't enough: the right offset depends on the
11+
# desktop scale (fractional scales such as 133 % on GNOME or Hyprland come out
12+
# wrong). Instead, the bundle's copy of exactly that engine (debug, profile and
13+
# release, matched by SHA-256) has that blocklist entry renamed to a vendor no
14+
# driver reports, a string of the same length so nothing else in the library
15+
# moves, and blits like it does on Intel and AMD. Checked on an RTX 5060 with
16+
# driver 615.78.08 (GNOME on Wayland, 133 %). Any other engine is left alone.
17+
#
18+
# Remove this file and its call in CMakeLists.txt when moving to Flutter 3.50.1,
19+
# after checking 3.50.1 on NVIDIA at a fractional scale.
20+
function(fix_flutter_3_50_0_engine library)
21+
file(SHA256 "${library}" hash)
22+
# Engine of Flutter 3.50.0: debug, profile, release.
23+
set(broken
24+
f38c8d6a0ef588b58daccdecaf2000f5cbdad267979369560c347a40af3eb258
25+
c31a78ca3aec4413815cb277b60ab4c1d42d4f00dd15bb3c1c21496f718e9786
26+
cb40d5867033badfa1a38072fab83f1c60ec1520c303a4810f49979f0ba5df04)
27+
# The same three after the correction.
28+
set(fixed
29+
0670e5e867807b2d07cffb30efacc23b2eb0c7e9b9abbf3334eebf6d10e6682e
30+
a11eeafeb542e1a2853b9c9a64708cf61a28466bcb0134c83e7260b61dccc267
31+
9d44e31942d73bcc26b1df6e1bd75235552792d58f0559e795c0608b13eb8c02)
32+
list(FIND broken "${hash}" index)
33+
if(index EQUAL -1)
34+
return()
35+
endif()
36+
list(GET fixed ${index} expected)
37+
# The entry is the only "NVIDIA" between NUL bytes in the library. Byte for
38+
# byte, whatever the locale.
39+
execute_process(
40+
COMMAND "${CMAKE_COMMAND}" -E env LC_ALL=C sed -i
41+
"s/\\x00NVIDIA\\x00/\\x00NOBLKL\\x00/"
42+
"${library}"
43+
RESULT_VARIABLE result)
44+
file(SHA256 "${library}" hash)
45+
if(NOT result EQUAL 0 OR NOT hash STREQUAL expected)
46+
message(FATAL_ERROR
47+
"Could not correct the Flutter 3.50.0 engine in ${library} (flutter_3_50_0_fix.cmake)")
48+
endif()
49+
message(STATUS "Let the Flutter 3.50.0 engine blit on NVIDIA: ${library}")
50+
endfunction()

0 commit comments

Comments
 (0)