Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 14b68c2

Browse files
[Fuchsia] Enable sound null safety everywhere (#51355)
This change enables null_safety on fuchsia everywhere and remove the legacy conditions. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent c05131e commit 14b68c2

File tree

17 files changed

+39
-120
lines changed

17 files changed

+39
-120
lines changed

shell/platform/fuchsia/dart_runner/dart_component_controller.cc

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,6 @@ bool DartComponentController::SetUpFromKernel() {
310310
manifest.size());
311311
Dart_Handle library = Dart_Null();
312312

313-
bool first_library = true;
314-
bool result_sound_null_safety = false;
315313
for (size_t start = 0; start < manifest.size();) {
316314
size_t end = str.find("\n", start);
317315
if (end == std::string::npos) {
@@ -330,31 +328,11 @@ bool DartComponentController::SetUpFromKernel() {
330328
Dart_ExitScope();
331329
return false;
332330
}
333-
bool sound_null_safety = Dart_DetectNullSafety(
334-
/*script_uri=*/nullptr, /*package_config=*/nullptr,
335-
/*original_working_directory=*/nullptr,
336-
isolate_snapshot_data_.address(),
337-
/*isolate_snapshot_instructions=*/nullptr, kernel.address(),
338-
kernel.size());
339-
340-
if (first_library) {
341-
result_sound_null_safety = sound_null_safety;
342-
first_library = false;
343-
} else if (sound_null_safety != result_sound_null_safety) {
344-
FML_LOG(ERROR) << "Inconsistent sound null safety";
345-
return false;
346-
}
347-
348331
kernel_peices_.emplace_back(std::move(kernel));
349332
}
350333

351-
Dart_IsolateFlags isolate_flags;
352-
Dart_IsolateFlagsInitialize(&isolate_flags);
353-
isolate_flags.null_safety = result_sound_null_safety;
354-
355334
if (!CreateIsolate(isolate_snapshot_data_.address(),
356-
/*isolate_snapshot_instructions=*/nullptr,
357-
&isolate_flags)) {
335+
/*isolate_snapshot_instructions=*/nullptr)) {
358336
return false;
359337
}
360338

@@ -404,15 +382,13 @@ bool DartComponentController::SetUpFromAppSnapshot() {
404382
isolate_data = isolate_snapshot_data_.address();
405383
isolate_instructions = nullptr;
406384
}
407-
return CreateIsolate(isolate_data, isolate_instructions,
408-
/*isolate_flags=*/nullptr);
385+
return CreateIsolate(isolate_data, isolate_instructions);
409386
#endif // defined(AOT_RUNTIME)
410387
}
411388

412389
bool DartComponentController::CreateIsolate(
413390
const uint8_t* isolate_snapshot_data,
414-
const uint8_t* isolate_snapshot_instructions,
415-
Dart_IsolateFlags* isolate_flags) {
391+
const uint8_t* isolate_snapshot_instructions) {
416392
// Create the isolate from the snapshot.
417393
char* error = nullptr;
418394

@@ -423,9 +399,13 @@ bool DartComponentController::CreateIsolate(
423399
auto state = new std::shared_ptr<tonic::DartState>(new tonic::DartState(
424400
namespace_fd, [this](Dart_Handle result) { MessageEpilogue(result); }));
425401

402+
Dart_IsolateFlags isolate_flags;
403+
Dart_IsolateFlagsInitialize(&isolate_flags);
404+
isolate_flags.null_safety = true;
405+
426406
isolate_ = Dart_CreateIsolateGroup(
427407
url_.c_str(), label_.c_str(), isolate_snapshot_data,
428-
isolate_snapshot_instructions, isolate_flags, state, state, &error);
408+
isolate_snapshot_instructions, &isolate_flags, state, state, &error);
429409
if (!isolate_) {
430410
FML_LOG(ERROR) << "Dart_CreateIsolateGroup failed: " << error;
431411
return false;

shell/platform/fuchsia/dart_runner/dart_component_controller.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ class DartComponentController
6161
bool SetUpFromAppSnapshot();
6262

6363
bool CreateIsolate(const uint8_t* isolate_snapshot_data,
64-
const uint8_t* isolate_snapshot_instructions,
65-
Dart_IsolateFlags* isolate_flags);
64+
const uint8_t* isolate_snapshot_instructions);
6665

6766
// |Echo|
6867
void EchoString(fidl::StringPtr value, EchoStringCallback callback) override;

shell/platform/fuchsia/dart_runner/dart_test_component_controller.cc

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ bool DartTestComponentController::SetUpFromKernel() {
242242
manifest.size());
243243
Dart_Handle library = Dart_Null();
244244

245-
bool first_library = true;
246-
bool result_sound_null_safety = false;
247245
for (size_t start = 0; start < manifest.size();) {
248246
size_t end = str.find("\n", start);
249247
if (end == std::string::npos) {
@@ -260,31 +258,11 @@ bool DartTestComponentController::SetUpFromKernel() {
260258
FML_LOG(ERROR) << "Cannot load kernel from namespace: " << path;
261259
return false;
262260
}
263-
bool sound_null_safety = Dart_DetectNullSafety(
264-
/*script_uri=*/nullptr, /*package_config=*/nullptr,
265-
/*original_working_directory=*/nullptr,
266-
isolate_snapshot_data_.address(),
267-
/*isolate_snapshot_instructions=*/nullptr, kernel.address(),
268-
kernel.size());
269-
270-
if (first_library) {
271-
result_sound_null_safety = sound_null_safety;
272-
first_library = false;
273-
} else if (sound_null_safety != result_sound_null_safety) {
274-
FML_LOG(ERROR) << "Inconsistent sound null safety";
275-
return false;
276-
}
277-
278261
kernel_peices_.emplace_back(std::move(kernel));
279262
}
280263

281-
Dart_IsolateFlags isolate_flags;
282-
Dart_IsolateFlagsInitialize(&isolate_flags);
283-
isolate_flags.null_safety = result_sound_null_safety;
284-
285264
if (!CreateIsolate(isolate_snapshot_data_.address(),
286-
/*isolate_snapshot_instructions=*/nullptr,
287-
&isolate_flags)) {
265+
/*isolate_snapshot_instructions=*/nullptr)) {
288266
return false;
289267
}
290268

@@ -333,15 +311,13 @@ bool DartTestComponentController::SetUpFromAppSnapshot() {
333311
isolate_data = isolate_snapshot_data_.address();
334312
isolate_instructions = nullptr;
335313
}
336-
return CreateIsolate(isolate_data, isolate_instructions,
337-
/*isolate_flags=*/nullptr);
314+
return CreateIsolate(isolate_data, isolate_instructions);
338315
#endif // defined(AOT_RUNTIME)
339316
}
340317

341318
bool DartTestComponentController::CreateIsolate(
342319
const uint8_t* isolate_snapshot_data,
343-
const uint8_t* isolate_snapshot_instructions,
344-
Dart_IsolateFlags* isolate_flags) {
320+
const uint8_t* isolate_snapshot_instructions) {
345321
// Create the isolate from the snapshot.
346322
char* error = nullptr;
347323

@@ -352,9 +328,13 @@ bool DartTestComponentController::CreateIsolate(
352328
auto state = new std::shared_ptr<tonic::DartState>(new tonic::DartState(
353329
namespace_fd, [this](Dart_Handle result) { MessageEpilogue(result); }));
354330

331+
Dart_IsolateFlags isolate_flags;
332+
Dart_IsolateFlagsInitialize(&isolate_flags);
333+
isolate_flags.null_safety = true;
334+
355335
isolate_ = Dart_CreateIsolateGroup(
356336
url_.c_str(), label_.c_str(), isolate_snapshot_data,
357-
isolate_snapshot_instructions, isolate_flags, state, state, &error);
337+
isolate_snapshot_instructions, &isolate_flags, state, state, &error);
358338
if (!isolate_) {
359339
FML_LOG(ERROR) << "Dart_CreateIsolateGroup failed: " << error;
360340
return false;

shell/platform/fuchsia/dart_runner/dart_test_component_controller.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ class DartTestComponentController
7777
bool SetUpFromAppSnapshot();
7878

7979
bool CreateIsolate(const uint8_t* isolate_snapshot_data,
80-
const uint8_t* isolate_snapshot_instructions,
81-
Dart_IsolateFlags* isolate_flags);
80+
const uint8_t* isolate_snapshot_instructions);
8281

8382
// |ComponentController|
8483
void Kill() override;

shell/platform/fuchsia/dart_runner/service_isolate.cc

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,9 @@ Dart_Isolate CreateServiceIsolate(
122122
}
123123
#endif
124124

125-
bool is_null_safe =
126-
Dart_DetectNullSafety(nullptr, // script_uri
127-
nullptr, // package_config
128-
nullptr, // original_working_directory
129-
vmservice_data, // snapshot_data
130-
vmservice_instructions, // snapshot_instructions
131-
nullptr, // kernel_buffer
132-
0u // kernel_buffer_size
133-
);
134-
135125
Dart_IsolateFlags flags;
136126
Dart_IsolateFlagsInitialize(&flags);
137-
flags.null_safety = is_null_safe;
127+
flags.null_safety = true;
138128

139129
auto state = new std::shared_ptr<tonic::DartState>(new tonic::DartState());
140130
Dart_Isolate isolate = Dart_CreateIsolateGroup(

shell/platform/fuchsia/dart_runner/tests/startup_integration_test/dart_echo_server/BUILD.gn

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import("//flutter/tools/fuchsia/gn-sdk/src/package.gni")
1111
dart_library("lib") {
1212
testonly = true
1313
package_name = "dart_echo_server"
14-
null_safe = true
1514

1615
source_dir = "."
1716
sources = [ "main.dart" ]
@@ -20,7 +19,6 @@ dart_library("lib") {
2019
# Dart component that serves the test Echo FIDL protocol, built using the Dart AOT runner
2120
dart_component("aot_component") {
2221
testonly = true
23-
null_safe = true
2422

2523
main_package = "dart_echo_server"
2624
manifest = "meta/dart-aot-echo-server.cml"
@@ -32,7 +30,6 @@ dart_component("aot_component") {
3230
# Dart component that serves the test Echo FIDL protocol, built using the Dart AOT runner
3331
dart_component("jit_component") {
3432
testonly = true
35-
null_safe = true
3633

3734
main_package = "dart_echo_server"
3835
manifest = "meta/dart-jit-echo-server.cml"

shell/platform/fuchsia/flutter/tests/integration/embedder/parent-view/lib/parent_view.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class TestApp {
5050
this.focusable = true}) {}
5151

5252
void run() {
53-
childView.create(focusable, (ByteData reply) {
53+
childView.create(focusable, (ByteData? reply) {
5454
// Set up window allbacks.
5555
window.onPointerDataPacket = (PointerDataPacket packet) {
5656
for (final data in packet.data) {
@@ -181,8 +181,8 @@ Future<int> _launchChildView() async {
181181
final message = Int8List.fromList([0x31]);
182182
final completer = new Completer<ByteData>();
183183
PlatformDispatcher.instance.sendPlatformMessage(
184-
'fuchsia/child_view', ByteData.sublistView(message), (ByteData reply) {
185-
completer.complete(reply);
184+
'fuchsia/child_view', ByteData.sublistView(message), (ByteData? reply) {
185+
completer.complete(reply!);
186186
});
187187

188188
return int.parse(

shell/platform/fuchsia/flutter/tests/integration/mouse-input/mouse-input-view/lib/mouse-input-view.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ class MyApp {
100100
}
101101

102102
void _reportMouseInput(
103-
{double localX,
104-
double localY,
105-
int timeReceived,
106-
int buttons,
107-
String phase,
108-
double wheelXPhysicalPixel,
109-
double wheelYPhysicalPixel}) {
103+
{required double localX,
104+
required double localY,
105+
required int timeReceived,
106+
required int buttons,
107+
required String phase,
108+
required double wheelXPhysicalPixel,
109+
required double wheelYPhysicalPixel}) {
110110
print('mouse-input-view reporting mouse input to MouseInputListener');
111111
final message = ByteData.sublistView(utf8.encode(json.encode({
112112
'method': 'MouseInputListener.ReportMouseInput',
@@ -115,7 +115,7 @@ class MyApp {
115115
'time_received': timeReceived,
116116
'component_name': 'touch-input-view',
117117
'buttons': buttons,
118-
'phase': 'asdf',
118+
'phase': phase,
119119
'wheel_x_physical_pixel': wheelXPhysicalPixel,
120120
'wheel_y_physical_pixel': wheelYPhysicalPixel,
121121
})));

shell/platform/fuchsia/flutter/tests/integration/text-input/text-input-view/BUILD.gn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ dart_library("lib") {
1313
package_name = "text-input-view"
1414
sources = [ "text_input_view.dart" ]
1515
deps = [ "//flutter/shell/platform/fuchsia/dart:args" ]
16-
null_safe = true
1716
}
1817

1918
flutter_component("component") {
@@ -22,7 +21,6 @@ flutter_component("component") {
2221
manifest = rebase_path("meta/text-input-view.cml")
2322
main_package = "text-input-view"
2423
main_dart = "text_input_view.dart"
25-
sound_null_safety = true
2624
deps = [ ":lib" ]
2725
}
2826

shell/platform/fuchsia/flutter/tests/integration/touch-input/embedding-flutter-view/lib/embedding-flutter-view.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class TestApp {
5353
}
5454

5555
void run() {
56-
childView.create(focusable, (ByteData reply) {
56+
childView.create(focusable, (ByteData? reply) {
5757
// Set up window callbacks.
5858
window.onPointerDataPacket = (PointerDataPacket packet) {
5959
this.pointerDataPacket(packet);
@@ -161,7 +161,7 @@ class TestApp {
161161
window.scheduleFrame();
162162
}
163163

164-
void _reportTouchInput({double localX, double localY, int timeReceived}) {
164+
void _reportTouchInput({required double localX, required double localY, required int timeReceived}) {
165165
print('embedding-flutter-view reporting touch input to TouchInputListener');
166166
final message = utf8.encode(json.encode({
167167
'method': 'TouchInputListener.ReportTouchInput',
@@ -219,8 +219,8 @@ Future<int> _launchChildView() async {
219219
final message = Int8List.fromList([0x31]);
220220
final completer = new Completer<ByteData>();
221221
PlatformDispatcher.instance.sendPlatformMessage(
222-
'fuchsia/child_view', ByteData.sublistView(message), (ByteData reply) {
223-
completer.complete(reply);
222+
'fuchsia/child_view', ByteData.sublistView(message), (ByteData? reply) {
223+
completer.complete(reply!);
224224
});
225225

226226
return int.parse(

0 commit comments

Comments
 (0)