1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
|