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

Flutter 3.19.x made wayland an unconditional requirement #144635

Open
aduskett opened this issue Mar 5, 2024 · 6 comments
Open

Flutter 3.19.x made wayland an unconditional requirement #144635

aduskett opened this issue Mar 5, 2024 · 6 comments
Labels
engine flutter/engine repository. See also e: labels. P3 Issues that are less important to the Flutter project platform-linux Building on or for Linux specifically team-engine Owned by Engine team triaged-engine Triaged by Engine team

Comments

@aduskett
Copy link

aduskett commented Mar 5, 2024

When compiling without Wayland, the following errors occur:

flutter/third_party/swiftshader/src/WSI/libWaylandClient.hpp:18:10: fatal error: 'wayland-client.h' file not found
../../flutter/third_party/swiftshader/src/WSI/WaylandSurfaceKHR.hpp:22:10: fatal error: 'wayland-client.h' file not found

I am not sure what exact commit caused the above error, but the above does not happen when compiling Flutter 3.16.8 using the Buildroot linux embedded sdk when cross-compiling an arm64 build

My testing was done via the Buildroot embedded Linux SDK and updating from Flutter 3.16.8 to 3.19.2 cross-compiling an ARM64 build of Flutter using an X64 host without Wayland.

Edit: Here are the configure commands:

>>> flutter-engine 3.16.8 Configuring
/usr/bin/sed -i -e "s%vulkan_use_x11.*%vulkan_use_x11 = false%g" output/build/flutter-engine-3.16.8/build_overrides/vulkan_headers.gni
/usr/bin/sed -i -e "s%vulkan_use_wayland.*%vulkan_use_wayland = false%g" output/build/flutter-engine-3.16.8/build_overrides/vulkan_headers.gni


cd output/build/flutter-engine-3.16.8 && rm -rf output/build/flutter-engine-3.16.8/out/linux_release_arm64 && PATH=output/host/share/depot_tools:"output/host/bin:output/host/sbin:/home/adam/.local/bin:/home/adam/Applications/bin:/home/adam/Applications/depot_tools:/home/adam/Applications/scripts:/snap/bin:/opt/zscaler/bin/:/usr/local/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/var/lib/snapd/snap/bin" PUB_CACHE=dl/br-flutter-pub-cache HOME=output/host/share/flutter/sdk ./flutter/tools/gn \
--clang \
--embedder-for-target \
--linux-cpu arm64 \
--no-build-embedder-examples \
--no-clang-static-analyzer \
--no-enable-unittests \
--no-goma \
--no-prebuilt-dart-sdk \
--no-stripped \
--use-mallinfo2 \
--runtime-mode release \
--target-os linux \
--target-sysroot output/host/aarch64-buildroot-linux-gnu/sysroot \
--target-toolchain output/build/flutter-engine-3.16.8/buildtools/linux-x64/clang \
--target-triple aarch64-unknown-linux-gnu \
--no-lto \
--enable-impeller-opengles \
--no-build-glfw-shell \
--disable-desktop-embeddings
@darshankawar darshankawar added in triage Presently being triaged by the triage team engine flutter/engine repository. See also e: labels. platform-linux Building on or for Linux specifically team-engine Owned by Engine team and removed in triage Presently being triaged by the triage team labels Mar 6, 2024
@aduskett
Copy link
Author

aduskett commented Mar 8, 2024

I have yet to figure out what has caused this issue. At this point, I assume it's because of the update to swiftshader.

@jonahwilliams jonahwilliams added P3 Issues that are less important to the Flutter project triaged-engine Triaged by Engine team labels Mar 12, 2024
@aduskett
Copy link
Author

It looks like flutter/engine@1750693 is the culprit.
Specifically, this file: https://github.com/flutter/engine/blame/main/build_overrides/vulkan_headers.gni

@aduskett
Copy link
Author

Thanks to @jwinarske for tracking down the real culprit:
meta-flutter/meta-flutter#452 (comment)

> @aduskett Looks like build parameters are not correctly being passed to swiftshader. Let me take a look at the swiftshader tree

meta-flutter/meta-flutter#452 (comment)

> @aduskett In swiftshader tip of tree there is support for either DirectFB or Direct2Display (D2D). It should be the same for flutter-engine swiftshader DEP commit.
> 
> ```
> if(SWIFTSHADER_BUILD_WSI_DIRECTFB)
>     find_library(DIRECTFB directfb)
>     find_path(DIRECTFB_INCLUDE_DIR directfb/directfb.h)
> endif(SWIFTSHADER_BUILD_WSI_DIRECTFB)
> if(SWIFTSHADER_BUILD_WSI_D2D)
>     find_library(D2D drm)
>     find_path(D2D_INCLUDE_DIR libdrm/drm.h)
> endif(SWIFTSHADER_BUILD_WSI_D2D)
> ...
> if(LINUX)
>     option_if_not_defined(SWIFTSHADER_BUILD_WSI_XCB "Build the XCB WSI support" TRUE)
>     option_if_not_defined(SWIFTSHADER_BUILD_WSI_WAYLAND "Build the Wayland WSI support" TRUE)
>     option_if_not_defined(SWIFTSHADER_BUILD_WSI_DIRECTFB "Build the DirectFB WSI support" FALSE)
>     option_if_not_defined(SWIFTSHADER_BUILD_WSI_D2D "Build the Direct-to-Display WSI support" FALSE)
> endif()
> ```
> 
> You just need to add some logic in flutter engine land to set it correctly.

meta-flutter/meta-flutter#452 (comment)

> In here: flutter/third_party/swiftshader/src/Vulkan/BUILD.gn
> 
> ```
>     if (ozone_platform_x11) {
>       defines += [ "VK_USE_PLATFORM_XCB_KHR" ]
>     }
>     if (ozone_platform_wayland) {
>       defines += [ "VK_USE_PLATFORM_WAYLAND_KHR" ]
>     }
> ```
> 
> It skips the desired options all together.
> 
> Work also needed in here: flutter/third_party/swiftshader/src/WSI/BUILD.gn

meta-flutter/meta-flutter#452 (comment)

> @aduskett Changes would need to be made upstream in the swiftshader repo, then it would eventually get picked up by the flutter engine master. Until then you would need to patch it. Might be easier to patch.

So, the problem is that Swiftshader and Flutter do not pass proper build flags to Swiftshader. Do you have any thoughts?

@jonahwilliams

This comment was marked as off-topic.

@jonahwilliams

This comment was marked as off-topic.

@aduskett
Copy link
Author

aduskett commented Mar 24, 2024

After digging around, here is the real culprit:
https://github.com/flutter/buildroot/blob/092e19a7caead03d25b161f33cff6ca520630aac/build/config/BUILDCONFIG.gn#L306

Specifically:
flutter/buildroot@d01da27

I am fixing the problem by running
sed "s%ozone_platform_x11.*%ozone_platform_x11 = false%g" -i build/config/BUILDCONFIG.gn and
sed "s%ozone_platform_wayland.*%ozone_platform_wayland = false%g" -i build/config/BUILDCONFIG.gn as a pre-configure hook if X11 or Wayland are unselected.

It's unfortunate that these values are hard coded, as Flutter works properly without Wayland or X11.

arnout pushed a commit to buildroot/buildroot that referenced this issue Mar 25, 2024
Add 0005-skip-configuration-dependency-if-unit-tests-are-disa.patch, which
fixes gtk+-3.0 being an unconditional requirement.

Other changes:
Flutter 3.19.x made Wayland and X11 an unconditional requirement, resulting in
the following errors when compiling:

"""
../../flutter/third_party/swiftshader/src/WSI/libWaylandClient.hpp:18:10: fatal error: 'wayland-client.h' file not found
   18 | #include <wayland-client.h>
      |          ^~~~~~~~~~~~~~~~~~

../../flutter/third_party/swiftshader/src/WSI/WaylandSurfaceKHR.cpp:15:
../../flutter/third_party/swiftshader/src/WSI/WaylandSurfaceKHR.hpp:22:10: fatal error: 'wayland-client.h' file not found
   22 | #include <wayland-client.h>
      |          ^~~~~~~~~~~~~~~~~~
1 error generated.
[1369/11229] CC obj/flutter/third_party/sqlite/sqlite.sqlite3.o
"""

After raising an issue found here:
flutter/flutter#144635 and after several hours of
searching, the problem is flutter/buildroot@d01da2716
which hardcodes the following values if building for a Linux platform:
  - ozone_platform_x11 = true
  - ozone_platform_wayland = true

As upstream maintainers listed the above as low priority (P3), a simple fix is
to add two additional sed calls in FLUTTER_ENGINE_VULKAN_X11_SUPPORT_FIXUP and
FLUTTER_ENGINE_VULKAN_WAYLAND_SUPPORT_FIXUP which set ozone_platform_x11 and
ozone_platform_wayland to the appropriate values.

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine flutter/engine repository. See also e: labels. P3 Issues that are less important to the Flutter project platform-linux Building on or for Linux specifically team-engine Owned by Engine team triaged-engine Triaged by Engine team
Projects
None yet
Development

No branches or pull requests

3 participants