-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[webview_flutter_lwe] Fix "channel sent a message from native to Flut…
…ter on a non-platform thread" error (#790)
- Loading branch information
1 parent
5b0f1ed
commit 9398e21
Showing
5 changed files
with
84 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/webview_flutter_lwe/tizen/src/message_dispatcher.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "message_dispatcher.h" | ||
|
||
#include <Ecore.h> | ||
|
||
MessageDispatcher::MessageDispatcher() { ecore_init(); } | ||
MessageDispatcher::~MessageDispatcher() { ecore_shutdown(); } | ||
|
||
void MessageDispatcher::dispatchTaskOnMainThread(std::function<void()>&& fn) { | ||
ecore_main_loop_thread_safe_call_sync( | ||
[](void* data) -> void* { | ||
auto fn = static_cast<std::function<void()>*>(data); | ||
if (fn) (*fn)(); | ||
return nullptr; | ||
}, | ||
&fn); | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/webview_flutter_lwe/tizen/src/message_dispatcher.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2025 Samsung Electronics Co., Ltd. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef FLUTTER_PLUGIN_MESSAGE_DISPATCHER_H_ | ||
#define FLUTTER_PLUGIN_MESSAGE_DISPATCHER_H_ | ||
|
||
#include <functional> | ||
|
||
class MessageDispatcher { | ||
public: | ||
MessageDispatcher(); | ||
~MessageDispatcher(); | ||
|
||
void dispatchTaskOnMainThread(std::function<void()>&& fn); | ||
}; | ||
|
||
#endif // FLUTTER_PLUGIN_MESSAGE_DISPATCHER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters