Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
jason feedback
  • Loading branch information
gaaclarke committed Sep 7, 2022
commit fa2be9d1b77648e82b735247f97f0b6783cff280
3 changes: 3 additions & 0 deletions lib/ui/ui_dart_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ void UIDartState::HandlePlatformMessage(
platform_message_handler_.lock();
if (handler) {
handler->HandlePlatformMessage(std::move(message));
} else {
FML_DLOG(WARNING) << "Dropping background isolate platform message on "
<< message->channel();
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions lib/ui/window/platform_message_response_dart_port.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "flutter/lib/ui/window/platform_message_response_dart_port.h"

#include <array>
#include <utility>

#include "flutter/common/task_runners.h"
Expand Down Expand Up @@ -51,13 +52,14 @@ void PlatformMessageResponseDartPort::Complete(
response_data.value.as_external_typed_data.peer = copy;
response_data.value.as_external_typed_data.callback = FreeFinalizer;

Dart_CObject* response_values[2] = {&response_identifier, &response_data};
std::array<Dart_CObject*, 2> response_values = {&response_identifier,
&response_data};

Dart_CObject response = {
.type = Dart_CObject_kArray,
};
response.value.as_array.length = 2;
response.value.as_array.values = response_values;
response.value.as_array.length = response_values.size();
response.value.as_array.values = response_values.data();

bool did_send = Dart_PostCObject(send_port_, &response);
FML_CHECK(did_send);
Expand Down
12 changes: 9 additions & 3 deletions lib/web_ui/lib/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ typedef PlatformMessageCallback = void Function(
typedef PlatformConfigurationChangedCallback = void Function(PlatformConfiguration configuration);
typedef ErrorCallback = bool Function(Object exception, StackTrace stackTrace);

// ignore: avoid_classes_with_only_static_members
/// A token that represents a root isolate.
class RootIsolateToken {
static RootIsolateToken? get instance {
throw UnsupportedError('Root isolate not identifiable on web.');
}
}

abstract class PlatformDispatcher {
static PlatformDispatcher get instance => engine.EnginePlatformDispatcher.instance;

Expand Down Expand Up @@ -55,9 +63,7 @@ abstract class PlatformDispatcher {
int identifier,
Object port);

int registerRootIsolate();

void registerBackgroundIsolate(int rootIsolateId);
void registerBackgroundIsolate(RootIsolateToken token);

PlatformMessageCallback? get onPlatformMessage;
set onPlatformMessage(PlatformMessageCallback? callback);
Expand Down
7 changes: 1 addition & 6 deletions lib/web_ui/lib/src/engine/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
}

@override
int registerRootIsolate() {
throw Exception("Isolates aren't supported in web.");
}

@override
void registerBackgroundIsolate(int rootIsolateId) {
void registerBackgroundIsolate(RootIsolateToken token) {
throw Exception("Isolates aren't supported in web.");
}

Expand Down
3 changes: 1 addition & 2 deletions shell/common/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,7 @@ void Shell::RunEngine(
task_runners_.GetUITaskRunner(),
fml::MakeCopyable(
[run_configuration = std::move(run_configuration),
weak_engine = weak_engine_, result,
platform_message_handler = platform_message_handler_]() mutable {
weak_engine = weak_engine_, result]() mutable {
if (!weak_engine) {
FML_LOG(ERROR)
<< "Could not launch engine with configuration - no engine.";
Expand Down