Skip to content

Commit 277ee2f

Browse files
[ONEMPERS-274] implemented freeMemory call support from dart (#14)
Co-authored-by: Sebastian Miasojed <[email protected]>
1 parent 2cdac7b commit 277ee2f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/wayland_display.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,18 @@ bool WaylandDisplay::SetupEngine(const std::string &bundle_path, const std::vect
617617
.icu_data_path = icu_data_path.c_str(),
618618
.command_line_argc = static_cast<int>(command_line_args_c.size()),
619619
.command_line_argv = command_line_args_c.data(),
620+
.platform_message_callback = [](const FlutterPlatformMessage *message, void *data) -> void {
621+
if (std::string(message->channel) == "flutter/platform" && std::string((char *)message->message).find("\"method\":\"freeMemory\"") != std::string::npos) {
622+
WaylandDisplay *const wd = get_wayland_display(data);
623+
if (wd->engine_) {
624+
auto ret = FlutterEngineNotifyLowMemoryWarning(wd->engine_);
625+
if (ret != kSuccess) {
626+
dbgE("Could not handle platform message request\n");
627+
}
628+
FlutterEngineSendPlatformMessageResponse(wd->engine_, message->response_handle, nullptr, 0);
629+
}
630+
}
631+
},
620632
.vsync_callback = [](void *data, intptr_t baton) -> void {
621633
WaylandDisplay *const wd = get_wayland_display(data);
622634

0 commit comments

Comments
 (0)