aboutsummaryrefslogtreecommitdiffstats
path: root/meta-agl-flutter/recipes-graphics
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2022-07-27 19:19:58 -0400
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2022-07-29 23:01:27 +0000
commit71db09dfeb4ff55f1a95219be550708d4524c47d (patch)
treef0e7b506f2b0264fb6fb54fca626b49e4c0efe15 /meta-agl-flutter/recipes-graphics
parenteda84d25d819824d641cf89af1e4d61a5e946744 (diff)
ivi-homescreen: improve AGL integration
Changes: - For now add local patches for three changes that Marius has submitted upstream that fix issues with respect to running as a normal application against agl-compositor and configuration via the JSON configuration file. The first of these patches has been merged upstream, but bumping the level of meta-flutter to get it brings other rework that it seems perhaps better to wait on a tagged upstream release for. - Add another patch to add a '--app-id' command-line option to the embedder. This avoids needing to use a JSON configuration file for simple (i.e. non-homescreen) applications when running multiple apps against agl-compositor. The use of the example JSON file for the ivi-homescreen recipe itself has been left alone for now since it provides a reference for doing so. - Rename the embedder binary from "homescreen" to "flutter" to avoid collision with the existing Qt homescreen application in meta-agl-demo. This allows integrating Flutter applications into images using the Qt homescreen for testing in the period while a Flutter replacement is worked on. Discussion about possibly renaming the embedder to something more generic along these lines has started with upstream. - Split the embedder binary into a separate package from the ivi-homescreen package that contains the systemd unit file. We do not want the "homescreen" systemd unit when using the embedder in other images that use applaunchd, so this split seems the most straightforward way to avoid pulling it in. - Remove installing the "homescreen" system level systemd unit, as it does not get used in agl-image-flutter (it is installed as a user unit instead). Bug-AGL: SPEC-4485 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I9f02f4312cf8c77ab224a3de8114c7fc3f4f6d36
Diffstat (limited to 'meta-agl-flutter/recipes-graphics')
-rw-r--r--meta-agl-flutter/recipes-graphics/toyota/files/0001-Allow-the-embedder-to-run-as-a-regular-normal-applic.patch181
-rw-r--r--meta-agl-flutter/recipes-graphics/toyota/files/0002-shell-configuration-Obey-json-configuration-file.patch44
-rw-r--r--meta-agl-flutter/recipes-graphics/toyota/files/0003-shell-configuration-Fixes-to-general-options.patch52
-rw-r--r--meta-agl-flutter/recipes-graphics/toyota/files/0004-Add-app-id-command-line-argument.patch38
-rw-r--r--meta-agl-flutter/recipes-graphics/toyota/ivi-homescreen_aglflutter.inc48
5 files changed, 357 insertions, 6 deletions
diff --git a/meta-agl-flutter/recipes-graphics/toyota/files/0001-Allow-the-embedder-to-run-as-a-regular-normal-applic.patch b/meta-agl-flutter/recipes-graphics/toyota/files/0001-Allow-the-embedder-to-run-as-a-regular-normal-applic.patch
new file mode 100644
index 00000000..5b63e20e
--- /dev/null
+++ b/meta-agl-flutter/recipes-graphics/toyota/files/0001-Allow-the-embedder-to-run-as-a-regular-normal-applic.patch
@@ -0,0 +1,181 @@
+From 7f3f913ec5bea1d94c04f8a029db659c33e56dbf Mon Sep 17 00:00:00 2001
+From: Marius Vlad <mv0@users.noreply.github.com>
+Date: Sun, 24 Jul 2022 21:15:54 +0300
+Subject: [PATCH 1/3] Allow the embedder to run as a regular/normal application
+ (#71)
+
+* shell: Do not issue always the ready request
+
+Rather than sending the ready request always, just do it when we've
+found at least a background type of surface.
+
+This way we can have a flutter instance as a regular application but
+also as a shell client.
+
+This is a work-around for the time being, a much more suitable approach
+would be to have a mechanism that tells us when the client has finished
+loading or has it's first frame swapped (or something similar to that).
+
+Note that we need at least a background surface so not finding one
+assumes that we're a regular application (WINDOW_NORMAL).
+
+Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
+
+* shell: Do not attempt always bind to agl-shell interface
+
+This helps up running as a regular application in
+situations where we already have a client bound to the agl-shell
+interface.
+
+We can't really accept more than one client to bind to the interface and
+without a change in the protocol to avoid racy situations, it seems more
+natural for the embedder to infer if it actually needs to do that.
+
+When the protocol has been updated to include additional events to let
+clients that they've lost the race, we can remove this change.
+
+Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
+
+Co-authored-by: Marius Vlad <marius.vlad@collabora.com>
+---
+ shell/app.cc | 13 +++++++++++--
+ shell/wayland/display.cc | 18 +++++++++++++++---
+ shell/wayland/display.h | 8 +++++++-
+ shell/wayland/window.h | 2 +-
+ 4 files changed, 34 insertions(+), 7 deletions(-)
+
+diff --git a/shell/app.cc b/shell/app.cc
+index 03c33ff..3ca183b 100644
+--- a/shell/app.cc
++++ b/shell/app.cc
+@@ -25,8 +25,10 @@
+
+ App::App(const std::vector<Configuration::Config>& configs)
+ : m_wayland_display(std::make_shared<Display>(!configs[0].disable_cursor,
+- configs[0].cursor_theme)) {
++ configs[0].cursor_theme,
++ configs)) {
+ FML_DLOG(INFO) << "+App::App";
++ bool found_view_with_bg = false;
+
+ size_t index = 0;
+ m_views.reserve(configs.size());
+@@ -35,9 +37,16 @@ App::App(const std::vector<Configuration::Config>& configs)
+ view->Initialize();
+ m_views.emplace_back(std::move(view));
+ index++;
++
++ if (WaylandWindow::get_window_type(cfg.view.window_type) ==
++ WaylandWindow::WINDOW_BG)
++ found_view_with_bg = true;
+ }
+
+- m_wayland_display->AglShellDoReady();
++ // check that if we had a BG type and issue a ready() request for it,
++ // otherwise we're going to assume that this is a NORMAL/REGULAR application.
++ if (found_view_with_bg)
++ m_wayland_display->AglShellDoReady();
+
+ FML_DLOG(INFO) << "-App::App";
+ }
+diff --git a/shell/wayland/display.cc b/shell/wayland/display.cc
+index 06eba8c..5d78471 100644
+--- a/shell/wayland/display.cc
++++ b/shell/wayland/display.cc
+@@ -27,7 +27,9 @@
+ #include "constants.h"
+ #include "engine.h"
+
+-Display::Display(bool enable_cursor, std::string cursor_theme_name)
++Display::Display(bool enable_cursor,
++ std::string cursor_theme_name,
++ const std::vector<Configuration::Config>& configs)
+ : m_xkb_context(xkb_context_new(XKB_CONTEXT_NO_FLAGS)),
+ m_buffer_scale(1),
+ m_last_buffer_scale(m_buffer_scale),
+@@ -35,6 +37,15 @@ Display::Display(bool enable_cursor, std::string cursor_theme_name)
+ m_cursor_theme_name(std::move(cursor_theme_name)) {
+ FML_DLOG(INFO) << "+ Display()";
+
++ for (auto const& cfg : configs) {
++ // check if we actually need to bind to agl-shell
++ auto window_type = WaylandWindow::get_window_type(cfg.view.window_type);
++ if (window_type != WaylandWindow::WINDOW_NORMAL) {
++ m_bind_to_agl_shell = true;
++ break;
++ }
++ }
++
+ m_display = wl_display_connect(nullptr);
+ if (m_display == nullptr) {
+ FML_LOG(ERROR) << "Failed to connect to Wayland display. "
+@@ -46,7 +57,7 @@ Display::Display(bool enable_cursor, std::string cursor_theme_name)
+ wl_registry_add_listener(m_registry, &registry_listener, this);
+ wl_display_dispatch(m_display);
+
+- if (!m_agl_shell) {
++ if (!m_agl_shell && m_bind_to_agl_shell) {
+ FML_LOG(INFO) << "agl_shell extension not present";
+ }
+
+@@ -152,7 +163,8 @@ void Display::registry_handle_global(void* data,
+ wl_registry_bind(registry, name, &wl_seat_interface,
+ std::min(static_cast<uint32_t>(5), version)));
+ wl_seat_add_listener(d->m_seat, &seat_listener, d);
+- } else if (strcmp(interface, agl_shell_interface.name) == 0) {
++ } else if (strcmp(interface, agl_shell_interface.name) == 0 &&
++ d->m_bind_to_agl_shell) {
+ d->m_agl_shell = static_cast<struct agl_shell*>(
+ wl_registry_bind(registry, name, &agl_shell_interface,
+ std::min(static_cast<uint32_t>(1), version)));
+diff --git a/shell/wayland/display.h b/shell/wayland/display.h
+index af3d460..bf05b27 100644
+--- a/shell/wayland/display.h
++++ b/shell/wayland/display.h
+@@ -32,11 +32,15 @@
+ #include "static_plugins/text_input/text_input.h"
+ #include "xdg-shell-client-protocol.h"
+
++#include "configuration/configuration.h"
++
+ class Engine;
+
+ class Display {
+ public:
+- explicit Display(bool enable_cursor, std::string cursor_theme_name);
++ explicit Display(bool enable_cursor,
++ std::string cursor_theme_name,
++ const std::vector<Configuration::Config>& configs);
+
+ ~Display();
+
+@@ -96,6 +100,8 @@ class Display {
+ struct wl_shm* m_shm{};
+ struct wl_surface* m_base_surface{};
+
++ bool m_bind_to_agl_shell = false;
++
+ std::map<wl_surface*, Engine*> m_surface_engine_map;
+ wl_surface* m_active_surface{};
+ Engine* m_active_engine{};
+diff --git a/shell/wayland/window.h b/shell/wayland/window.h
+index c4fe5e6..4b5c726 100644
+--- a/shell/wayland/window.h
++++ b/shell/wayland/window.h
+@@ -79,6 +79,7 @@ class WaylandWindow {
+ wl_surface* GetBaseSurface() { return m_base_surface; }
+
+ uint32_t m_fps_counter;
++ static window_type get_window_type(const std::string& type);
+
+ private:
+ struct shm_buffer {
+@@ -157,5 +158,4 @@ class WaylandWindow {
+
+ static const struct wl_callback_listener frame_listener;
+
+- static window_type get_window_type(const std::string& type);
+ };
+--
+2.35.3
+
diff --git a/meta-agl-flutter/recipes-graphics/toyota/files/0002-shell-configuration-Obey-json-configuration-file.patch b/meta-agl-flutter/recipes-graphics/toyota/files/0002-shell-configuration-Obey-json-configuration-file.patch
new file mode 100644
index 00000000..b9a864c5
--- /dev/null
+++ b/meta-agl-flutter/recipes-graphics/toyota/files/0002-shell-configuration-Obey-json-configuration-file.patch
@@ -0,0 +1,44 @@
+From 36c7deb35719d2219dc6e868ab14d9a4ce984d1f Mon Sep 17 00:00:00 2001
+From: Marius Vlad <marius.vlad@collabora.com>
+Date: Mon, 25 Jul 2022 15:51:06 +0300
+Subject: [PATCH 2/3] shell/configuration: Obey json configuration file
+
+Setting the name of the application to kApplicationName, by default,
+would cause the check in getCliOverrides to always be true, which in
+turn will ignore whatever the user specified in the configuration file.
+
+Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
+---
+ shell/configuration/configuration.cc | 2 ++
+ shell/main.cc | 2 +-
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/shell/configuration/configuration.cc b/shell/configuration/configuration.cc
+index f8b1e13..616de48 100644
+--- a/shell/configuration/configuration.cc
++++ b/shell/configuration/configuration.cc
+@@ -220,6 +220,8 @@ std::vector<struct Configuration::Config> Configuration::ParseConfig(
+ if (cfg.view.height == 0) {
+ cfg.view.height = kDefaultViewHeight;
+ }
++ if (cfg.app_id.empty())
++ cfg.app_id = kApplicationName;
+
+ res.emplace_back(cfg);
+ }
+diff --git a/shell/main.cc b/shell/main.cc
+index 65c3f37..6fdd907 100644
+--- a/shell/main.cc
++++ b/shell/main.cc
+@@ -44,7 +44,7 @@ void RemoveArgument(std::vector<std::string>& args, const std::string& arg) {
+
+ int main(int argc, char** argv) {
+ struct Configuration::Config config {
+- .app_id = kApplicationName, .json_configuration_path{}, .cursor_theme{},
++ .app_id = {}, .json_configuration_path{}, .cursor_theme{},
+ .disable_cursor{}, .debug_backend{}, .view {}
+ };
+
+--
+2.35.3
+
diff --git a/meta-agl-flutter/recipes-graphics/toyota/files/0003-shell-configuration-Fixes-to-general-options.patch b/meta-agl-flutter/recipes-graphics/toyota/files/0003-shell-configuration-Fixes-to-general-options.patch
new file mode 100644
index 00000000..f06d4548
--- /dev/null
+++ b/meta-agl-flutter/recipes-graphics/toyota/files/0003-shell-configuration-Fixes-to-general-options.patch
@@ -0,0 +1,52 @@
+From a3a1421c3986bbafd9f91997eec7f2606ef67fc3 Mon Sep 17 00:00:00 2001
+From: Marius Vlad <marius.vlad@collabora.com>
+Date: Mon, 25 Jul 2022 15:53:17 +0300
+Subject: [PATCH 3/3] shell/configuration: Fixes to general options
+
+This patch avoids an automatic overwrite of the debug_backend and
+disable_cursor entries. If enabled in the configuration file, the test
+will always return true, basically overwriting to false.
+
+Also, use the correct entry in the README file for debug_backend.
+
+Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
+---
+ README.md | 2 +-
+ shell/configuration/configuration.cc | 6 ++++--
+ 2 files changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/README.md b/README.md
+index 7c162eb..d459f4c 100644
+--- a/README.md
++++ b/README.md
+@@ -175,7 +175,7 @@ Loads Single View
+
+ {
+ "disable_cursor":true,
+- "backend_debug":true,
++ "debug_backend":true,
+ "accessibility_features":31,
+ "view":{
+ "bundle_path":"/home/joel/development/gallery/.homescreen/x86/release",
+diff --git a/shell/configuration/configuration.cc b/shell/configuration/configuration.cc
+index 616de48..773724c 100644
+--- a/shell/configuration/configuration.cc
++++ b/shell/configuration/configuration.cc
+@@ -152,10 +152,12 @@ void Configuration::getCliOverrides(Config& instance, Config& cli) {
+ if (!cli.cursor_theme.empty()) {
+ instance.cursor_theme = cli.cursor_theme;
+ }
+- if (cli.disable_cursor != instance.disable_cursor) {
++ if (cli.disable_cursor == true &&
++ cli.disable_cursor != instance.disable_cursor) {
+ instance.disable_cursor = cli.disable_cursor;
+ }
+- if (cli.debug_backend != instance.debug_backend) {
++ if (cli.debug_backend == true &&
++ cli.debug_backend != instance.debug_backend) {
+ instance.debug_backend = cli.debug_backend;
+ }
+ if (!cli.view.vm_args.empty()) {
+--
+2.35.3
+
diff --git a/meta-agl-flutter/recipes-graphics/toyota/files/0004-Add-app-id-command-line-argument.patch b/meta-agl-flutter/recipes-graphics/toyota/files/0004-Add-app-id-command-line-argument.patch
new file mode 100644
index 00000000..6b9d4c3a
--- /dev/null
+++ b/meta-agl-flutter/recipes-graphics/toyota/files/0004-Add-app-id-command-line-argument.patch
@@ -0,0 +1,38 @@
+From 6a62efbebcdf17e3af57f04603aa5f0d61b0c1e2 Mon Sep 17 00:00:00 2001
+From: Scott Murray <scott.murray@konsulko.com>
+Date: Wed, 27 Jul 2022 18:23:32 -0400
+Subject: [PATCH] Add app-id command-line argument
+
+Add a command-line argument for specifying the app id, so that basic
+applications do not need to supply a full JSON configuration just to
+do so.
+
+Signed-off-by: Scott Murray <scott.murray@konsulko.com>
+---
+ shell/main.cc | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/shell/main.cc b/shell/main.cc
+index 6fdd907..662b7d1 100644
+--- a/shell/main.cc
++++ b/shell/main.cc
+@@ -151,6 +151,16 @@ int main(int argc, char** argv) {
+ FML_DLOG(INFO) << "Cursor Theme: " << config.cursor_theme;
+ RemoveArgument(config.view.vm_args, "--t=" + config.cursor_theme);
+ }
++ if (cl.HasOption("app-id")) {
++ cl.GetOptionValue("app-id", &config.app_id);
++ if (config.app_id.empty()) {
++ FML_LOG(ERROR)
++ << "--app-id option requires an argument (e.g. --app-id=gallery)";
++ return EXIT_FAILURE;
++ }
++ FML_DLOG(INFO) << "Application ID: " << config.app_id;
++ RemoveArgument(config.view.vm_args, "--app-id=" + config.app_id);
++ }
+ }
+
+ auto vm_arg_count = config.view.vm_args.size();
+--
+2.35.3
+
diff --git a/meta-agl-flutter/recipes-graphics/toyota/ivi-homescreen_aglflutter.inc b/meta-agl-flutter/recipes-graphics/toyota/ivi-homescreen_aglflutter.inc
index 48ba9d1d..3fea926e 100644
--- a/meta-agl-flutter/recipes-graphics/toyota/ivi-homescreen_aglflutter.inc
+++ b/meta-agl-flutter/recipes-graphics/toyota/ivi-homescreen_aglflutter.inc
@@ -1,18 +1,36 @@
-# Upstream is now pinning ivi-homescreen
+FILESEXTRAPATHS:append := "${THISDIR}/files:"
+
+SRC_URI += " \
+ file://0001-Allow-the-embedder-to-run-as-a-regular-normal-applic.patch \
+ file://0002-shell-configuration-Obey-json-configuration-file.patch \
+ file://0003-shell-configuration-Fixes-to-general-options.patch \
+ file://0004-Add-app-id-command-line-argument.patch \
+ file://config.json \
+"
+
+# Upstream is now pinning ivi-homescreen, but if it did need to be pinned
+# it can be done here.
#SRCREV = ""
# For now disable gstreamer to avoid needing to enable "commercial"
# licenses for the stated ffmpeg dependency.
PACKAGECONFIG:remove = "gstreamer"
-FILESEXTRAPATHS:append := "${THISDIR}/files:"
-SRC_URI += "file://config.json"
-
+#
# AGL specifics
+#
+
IVI_HOMESCREEN_APP_OVERRIDE = "--b=/usr/share/flutter/gallery --j=/usr/share/flutter/config.json"
SERVICE_UNIT = "Requires=agl-compositor.service\nAfter=agl-compositor.service"
SERVICE_INSTALL = "WantedBy=agl-session.target"
+
+# The "homescreen" naming of the embedder binary conflicts with the
+# Qt homescreen in meta-agl-demo. At least for now, rename it to
+# allow running Flutter apps in an image that uses the Qt homescreen
+# and launcher for testing.
+SERVICE_EXEC_START = "ExecStart=/usr/bin/flutter --f ${IVI_HOMESCREEN_APP_OVERRIDE} ${SERVICE_EXEC_START_PARAMS}"
+
# we have a regular/agl-driver user, so avoid setting one
SERVICE_ENVIRONMENT = ""
SERVICE_USER_GROUP = ""
@@ -20,10 +38,28 @@ SERVICE_RESTART = "Restart=on-failure"
# we need to install as user session, not root.
do_install:append() {
+ # The system level systemd unit is not required in AGL
+ rm -f ${D}{systemd_system_unitdir}/homescreen.service
+
install -d ${D}${systemd_user_unitdir}/agl-session.target.wants
install -D -m 0644 ${WORKDIR}/config.json ${D}${datadir}/flutter/config.json
- install -m0644 ${WORKDIR}/homescreen.service ${D}${systemd_user_unitdir}/homescreen.service
+ install -m 0644 ${WORKDIR}/homescreen.service ${D}${systemd_user_unitdir}/homescreen.service
ln -s ../homescreen.service ${D}${systemd_user_unitdir}/agl-session.target.wants/homescreen.service
+
+ # Rename embedder binary, see explanation above
+ mv ${D}${bindir}/homescreen ${D}${bindir}/flutter
}
-FILES:${PN} += " ${systemd_user_unitdir} ${datadir}/flutter/config.json"
+# Split the embedder binary into a separate package to allow reusing it
+# without the generated upstream systemd unit that ATM is still useful
+# for testing with the agl-image-flutter image. AGL will use either
+# the applaunchd systemd template or custom units in meta-agl-demo.
+PACKAGE_BEFORE_PN = "flutter-embedder-${FLUTTER_RUNTIME}"
+
+FILES:flutter-embedder-${FLUTTER_RUNTIME} = "${bindir}"
+
+FILES:${PN} += "${systemd_user_unitdir} ${datadir}/flutter/config.json"
+
+RDEPENDS:${PN} += "flutter-embedder-${FLUTTER_RUNTIME}"
+
+RDEPENDS:flutter-embedder-${FLUTTER_RUNTIME} += "flutter-engine-${FLUTTER_RUNTIME}"