Skip to content

Commit 101e03c

Browse files
authored
Return a JSON value for the Skia channel (#11717)
1 parent 7024722 commit 101e03c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

shell/common/fixtures/shell_test.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import 'dart:convert' show utf8;
5+
import 'dart:convert' show utf8, json;
66
import 'dart:isolate';
77
import 'dart:typed_data';
88
import 'dart:ui';
@@ -66,15 +66,20 @@ void testSkiaResourceCacheSendsResponse() {
6666
if (data == null) {
6767
throw 'Response must not be null.';
6868
}
69+
final String response = utf8.decode(data.buffer.asUint8List());
70+
final List<bool> jsonResponse = json.decode(response).cast<bool>();
71+
if (jsonResponse[0] != true) {
72+
throw 'Response was not true';
73+
}
6974
notifyNative();
7075
};
71-
const String json = '''{
76+
const String jsonRequest = '''{
7277
"method": "Skia.setResourceCacheMaxBytes",
7378
"args": 10000
7479
}''';
7580
window.sendPlatformMessage(
7681
'flutter/skia',
77-
Uint8List.fromList(utf8.encode(json)).buffer.asByteData(),
82+
Uint8List.fromList(utf8.encode(jsonRequest)).buffer.asByteData(),
7883
callback,
7984
);
8085
}

shell/common/shell.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,9 @@ void Shell::HandleEngineSkiaMessage(fml::RefPtr<PlatformMessage> message) {
959959
true);
960960
}
961961
if (response) {
962-
std::vector<uint8_t> data = {1};
962+
// The framework side expects this to be valid json encoded as a list.
963+
// Return `[true]` to signal success.
964+
std::vector<uint8_t> data = {'[', 't', 'r', 'u', 'e', ']'};
963965
response->Complete(
964966
std::make_unique<fml::DataMapping>(std::move(data)));
965967
}

0 commit comments

Comments
 (0)