summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2024-11-12 14:20:35 +0200
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2024-11-19 20:05:29 +0000
commit8dfcb150c8eb20aa13dbf2153090c47eabbb76f9 (patch)
tree9910f7e1f5bfd127344445ce9bfeedcc5be02dfb
parent1498e447e3d89a19cca863d32ef82b188d4e6718 (diff)
flutter-auto: Work-around for key keyboard event crash
This is a work-around to still allowing key keyboard go through but avoid passing an invalid messenger pointer to the flutter engine which would ultimately crash flutter-auto. Initially we had a workaround to avoid sending the key event altogether. Bug-AGL: SPEC-5272 Change-Id: I4df9f298e26470b5edd039b31346e2dc8e788a01 Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/30509 ci-image-boot-test: Jenkins Job builder account ci-image-build: Jenkins Job builder account Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> Tested-by: Jenkins Job builder account Reviewed-by: Joel Winarske <joel.winarske@gmail.com>
-rw-r--r--meta-agl-flutter/recipes-graphics/toyota/files/0001-flutter_desktop-Remove-asio-post-call.patch94
-rw-r--r--meta-agl-flutter/recipes-graphics/toyota/flutter-auto_aglflutter.inc3
2 files changed, 97 insertions, 0 deletions
diff --git a/meta-agl-flutter/recipes-graphics/toyota/files/0001-flutter_desktop-Remove-asio-post-call.patch b/meta-agl-flutter/recipes-graphics/toyota/files/0001-flutter_desktop-Remove-asio-post-call.patch
new file mode 100644
index 000000000..f9cfea44d
--- /dev/null
+++ b/meta-agl-flutter/recipes-graphics/toyota/files/0001-flutter_desktop-Remove-asio-post-call.patch
@@ -0,0 +1,94 @@
+From a69dfff93b41b30ae8e237817548baf50d0c1287 Mon Sep 17 00:00:00 2001
+From: Marius Vlad <marius.vlad@collabora.com>
+Date: Thu, 24 Oct 2024 14:45:35 +0300
+Subject: [PATCH] flutter_desktop: Remove asio::post call
+
+Do not dispatch/post the key event keycode using asio::post as that
+seems to cause crashes as the messenger pointer seems to be go out of
+scope or seems to be invalid.
+
+Bug-AGL: SPEC-5272
+Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
+---
+ shell/platform/homescreen/flutter_desktop.cc | 65 ++++++++++----------
+ 1 file changed, 31 insertions(+), 34 deletions(-)
+
+diff --git a/shell/platform/homescreen/flutter_desktop.cc b/shell/platform/homescreen/flutter_desktop.cc
+index bb5be4b..5d26dd9 100644
+--- a/shell/platform/homescreen/flutter_desktop.cc
++++ b/shell/platform/homescreen/flutter_desktop.cc
+@@ -161,40 +161,37 @@ std::future<bool> PostMessengerSendWithReply(
+ void* user_data) {
+ const auto promise(std::make_shared<std::promise<bool>>());
+ auto promise_future(promise->get_future());
+- asio::post(*messenger->GetEngine()->platform_task_runner->GetStrandContext(),
+- [&, promise, channel, message, message_size, reply, user_data]() {
+- FlutterPlatformMessageResponseHandle* response_handle = nullptr;
+- if (reply != nullptr && user_data != nullptr) {
+- const FlutterEngineResult result =
+- LibFlutterEngine->PlatformMessageCreateResponseHandle(
+- messenger->GetEngine()->flutter_engine, reply,
+- user_data, &response_handle);
+- if (result != kSuccess) {
+- spdlog::error("Failed to create response handle");
+- promise->set_value(false);
+- return;
+- }
+- }
+-
+- auto platform_message = std::make_unique<FlutterPlatformMessage>();
+- platform_message->struct_size = sizeof(FlutterPlatformMessage);
+- platform_message->channel = channel;
+- platform_message->message = message;
+- platform_message->message_size = message_size;
+- platform_message->response_handle = response_handle;
+-
+- const FlutterEngineResult message_result =
+- LibFlutterEngine->SendPlatformMessage(
+- messenger->GetEngine()->flutter_engine,
+- platform_message.release());
+-
+- if (response_handle != nullptr) {
+- LibFlutterEngine->PlatformMessageReleaseResponseHandle(
+- messenger->GetEngine()->flutter_engine, response_handle);
+- }
+-
+- promise->set_value(message_result == kSuccess);
+- });
++
++ FlutterPlatformMessageResponseHandle* response_handle = nullptr;
++ if (reply != nullptr && user_data != nullptr) {
++ const FlutterEngineResult result =
++ LibFlutterEngine->PlatformMessageCreateResponseHandle(
++ messenger->GetEngine()->flutter_engine, reply, user_data,
++ &response_handle);
++ if (result != kSuccess) {
++ spdlog::error("Failed to create response handle");
++ promise->set_value(false);
++ return promise_future;
++ }
++ }
++
++ auto platform_message = std::make_unique<FlutterPlatformMessage>();
++ platform_message->struct_size = sizeof(FlutterPlatformMessage);
++ platform_message->channel = channel;
++ platform_message->message = message;
++ platform_message->message_size = message_size;
++ platform_message->response_handle = response_handle;
++
++ const FlutterEngineResult message_result =
++ LibFlutterEngine->SendPlatformMessage(
++ messenger->GetEngine()->flutter_engine, platform_message.release());
++
++ if (response_handle != nullptr) {
++ LibFlutterEngine->PlatformMessageReleaseResponseHandle(
++ messenger->GetEngine()->flutter_engine, response_handle);
++ }
++
++ promise->set_value(message_result == kSuccess);
+ return promise_future;
+ }
+
+--
+2.43.0
+
diff --git a/meta-agl-flutter/recipes-graphics/toyota/flutter-auto_aglflutter.inc b/meta-agl-flutter/recipes-graphics/toyota/flutter-auto_aglflutter.inc
index 6c1503024..29c023fca 100644
--- a/meta-agl-flutter/recipes-graphics/toyota/flutter-auto_aglflutter.inc
+++ b/meta-agl-flutter/recipes-graphics/toyota/flutter-auto_aglflutter.inc
@@ -4,6 +4,9 @@ EGLCONFIG_FALLBACK = "${@bb.utils.contains_any('AGL_FEATURES', 'agl-rdp agl-kvm-
SRC_URI:append:use-nxp-bsp = " file://0001-Disable-on_frame_base_surface-wl_surface_commit.patch"
SRC_URI:append = " ${EGLCONFIG_FALLBACK}"
+# necessary to avoid crashing flutter-auto when a key keyboard event is emitted
+SRC_URI:append = " file://0001-flutter_desktop-Remove-asio-post-call.patch"
+
# Disable WIP webview plugin on 32-bit ARM platforms for now, as build
# failures have been seen on qemuarm and beaglebone.
PACKAGECONFIG:remove:arm = "webview_flutter_view"