diff --git a/engine/src/flutter/lib/web_ui/analysis_options.yaml b/engine/src/flutter/lib/web_ui/analysis_options.yaml index 60918b30bb..ef333c896d 100644 --- a/engine/src/flutter/lib/web_ui/analysis_options.yaml +++ b/engine/src/flutter/lib/web_ui/analysis_options.yaml @@ -8,4 +8,5 @@ include: ../../analysis_options.yaml linter: rules: - public_member_api_docs: false \ No newline at end of file + public_member_api_docs: false + unawaited_futures: true diff --git a/engine/src/flutter/lib/web_ui/dev/chrome.dart b/engine/src/flutter/lib/web_ui/dev/chrome.dart index f793153cb8..cfe124fdb8 100644 --- a/engine/src/flutter/lib/web_ui/dev/chrome.dart +++ b/engine/src/flutter/lib/web_ui/dev/chrome.dart @@ -191,6 +191,12 @@ Future _spawnChromiumProcess(String executable, List args, { St // A precaution that avoids accumulating browser processes, in case the // glibc bug doesn't cause the browser to quit and we keep looping and // launching more processes. + + // It's OK to not await the future here, as this is a best-effort process + // clean-up only. If we're executing this line, this means things are off + // the rails already due to the glibc bug, and we're just scrambling to keep + // the system stable. + // ignore: unawaited_futures process.exitCode.timeout(const Duration(seconds: 1), onTimeout: () { process.kill(); return -1; diff --git a/engine/src/flutter/lib/web_ui/dev/felt.dart b/engine/src/flutter/lib/web_ui/dev/felt.dart index ec036869aa..6088acbc0e 100644 --- a/engine/src/flutter/lib/web_ui/dev/felt.dart +++ b/engine/src/flutter/lib/web_ui/dev/felt.dart @@ -71,7 +71,7 @@ Future main(List rawArgs) async { io.exit(io.exitCode); } -Future _listenToShutdownSignals() async { +void _listenToShutdownSignals() { io.ProcessSignal.sigint.watch().listen((_) async { print('Received SIGINT. Shutting down.'); await cleanup(); diff --git a/engine/src/flutter/lib/web_ui/dev/safari_macos.dart b/engine/src/flutter/lib/web_ui/dev/safari_macos.dart index 1cbbed65f2..8961649476 100644 --- a/engine/src/flutter/lib/web_ui/dev/safari_macos.dart +++ b/engine/src/flutter/lib/web_ui/dev/safari_macos.dart @@ -67,7 +67,7 @@ class SafariMacOs extends Browser { // Clean up trampoline files/directories before exiting felt. cleanupCallbacks.add(() async { if (trampolineDirectory.existsSync()) { - trampolineDirectory.delete(recursive: true); + await trampolineDirectory.delete(recursive: true); } }); diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart index 44d7fd01bf..b66660f1fc 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/canvaskit/font_fallbacks.dart @@ -291,7 +291,7 @@ Future findFontsForMissingCodeunits(List codeUnits) async { // we try looking them up in the symbols and emojis fonts. if (missingCodeUnits.isNotEmpty || unmatchedCodeUnits.isNotEmpty) { if (!data.registeredSymbolsAndEmoji) { - _registerSymbolsAndEmoji(); + await _registerSymbolsAndEmoji(); } else { if (!notoDownloadQueue.isPending) { printWarning( diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/html_image_codec.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/html_image_codec.dart index 7acd8f89a6..3c6e4bdd97 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/html_image_codec.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/html_image_codec.dart @@ -47,6 +47,10 @@ class HtmlCodec implements ui.Codec { final html.ImageElement imgElement = html.ImageElement(); imgElement.src = src; setJsProperty(imgElement, 'decoding', 'async'); + + // Ignoring the returned future on purpose because we're communicating + // through the `completer`. + // ignore: unawaited_futures imgElement.decode().then((dynamic _) { chunkCallback?.call(100, 100); int naturalWidth = imgElement.naturalWidth; diff --git a/engine/src/flutter/lib/web_ui/lib/src/engine/picture.dart b/engine/src/flutter/lib/web_ui/lib/src/engine/picture.dart index 1ca8cd411a..0968992f89 100644 --- a/engine/src/flutter/lib/web_ui/lib/src/engine/picture.dart +++ b/engine/src/flutter/lib/web_ui/lib/src/engine/picture.dart @@ -65,7 +65,12 @@ class EnginePicture implements ui.Picture { // The image loads asynchronously. We need to wait before returning, // otherwise the returned HtmlImage will be temporarily unusable. final Completer onImageLoaded = Completer.sync(); + + // Ignoring the returned futures from onError and onLoad because we're + // communicating through the `onImageLoaded` completer. + // ignore: unawaited_futures imageElement.onError.first.then(onImageLoaded.completeError); + // ignore: unawaited_futures imageElement.onLoad.first.then((_) { onImageLoaded.complete(HtmlImage( imageElement, diff --git a/engine/src/flutter/lib/web_ui/test/channel_buffers_test.dart b/engine/src/flutter/lib/web_ui/test/channel_buffers_test.dart index 21ba2d94ae..0c68681fab 100644 --- a/engine/src/flutter/lib/web_ui/test/channel_buffers_test.dart +++ b/engine/src/flutter/lib/web_ui/test/channel_buffers_test.dart @@ -60,6 +60,10 @@ void testMain() { final Completer completer = Completer(); scheduleMicrotask(() { log.add('before drain, microtask'); }); log.add('before drain'); + + // Ignoring the returned future because the completion of the drain is + // communicated using the `completer`. + // ignore: unawaited_futures buffers.drain(channel, (ByteData? drainedData, ui.PlatformMessageResponseCallback drainedCallback) async { log.add('callback'); completer.complete(); diff --git a/engine/src/flutter/lib/web_ui/test/engine/surface/scene_builder_test.dart b/engine/src/flutter/lib/web_ui/test/engine/surface/scene_builder_test.dart index 5df852363c..34ef5c1760 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/surface/scene_builder_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/surface/scene_builder_test.dart @@ -20,8 +20,8 @@ void main() { } void testMain() { - setUpAll(() { - ui.webOnlyInitializePlatform(); + setUpAll(() async { + await ui.webOnlyInitializePlatform(); }); group('SceneBuilder', () { diff --git a/engine/src/flutter/lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart b/engine/src/flutter/lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart index 06d945ff62..add593d18d 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/surface/shaders/shader_builder_test.dart @@ -24,7 +24,7 @@ void testMain() { ')'; setUpAll(() async { - webOnlyInitializePlatform(); + await webOnlyInitializePlatform(); }); group('Shader Declarations', () { diff --git a/engine/src/flutter/lib/web_ui/test/engine/util_test.dart b/engine/src/flutter/lib/web_ui/test/engine/util_test.dart index 4b77725512..55099191d3 100644 --- a/engine/src/flutter/lib/web_ui/test/engine/util_test.dart +++ b/engine/src/flutter/lib/web_ui/test/engine/util_test.dart @@ -132,7 +132,7 @@ void testMain() { test('futurize converts error string to exception', () async { try { - futurize((Callback callback) { + await futurize((Callback callback) { return 'this is an error'; }); fail('Expected it to throw'); @@ -159,7 +159,7 @@ void testMain() { test('futurize converts sync null into a sync operation failure', () async { try { - futurize((Callback callback) { + await futurize((Callback callback) { callback(null); return null; }); diff --git a/engine/src/flutter/lib/web_ui/test/window_test.dart b/engine/src/flutter/lib/web_ui/test/window_test.dart index 71c1243775..f0ed95683b 100644 --- a/engine/src/flutter/lib/web_ui/test/window_test.dart +++ b/engine/src/flutter/lib/web_ui/test/window_test.dart @@ -143,7 +143,7 @@ void testMain() { ), useSingle: false); expect(window.browserHistory, isA()); final List executionOrder = []; - window.handleNavigationMessage( + await window.handleNavigationMessage( const JSONMethodCodec().encodeMethodCall(const MethodCall( 'selectSingleEntryHistory', null, @@ -151,7 +151,7 @@ void testMain() { ).then((bool data) { executionOrder.add('1'); }); - window.handleNavigationMessage( + await window.handleNavigationMessage( const JSONMethodCodec().encodeMethodCall(const MethodCall( 'selectMultiEntryHistory', null, @@ -159,7 +159,7 @@ void testMain() { ).then((bool data) { executionOrder.add('2'); }); - window.handleNavigationMessage( + await window.handleNavigationMessage( const JSONMethodCodec().encodeMethodCall(const MethodCall( 'selectSingleEntryHistory', null, diff --git a/engine/src/flutter/lib/web_ui/tool/unicode_sync_script.dart b/engine/src/flutter/lib/web_ui/tool/unicode_sync_script.dart index 6b87fb014b..c2118f566e 100644 --- a/engine/src/flutter/lib/web_ui/tool/unicode_sync_script.dart +++ b/engine/src/flutter/lib/web_ui/tool/unicode_sync_script.dart @@ -124,7 +124,7 @@ Future main(List arguments) async { result['dry'] as bool, ); - syncer.perform(); + await syncer.perform(); } PropertiesSyncer getSyncer( diff --git a/engine/src/flutter/testing/dart/channel_buffers_test.dart b/engine/src/flutter/testing/dart/channel_buffers_test.dart index e86d5f3493..8781d0d29c 100644 --- a/engine/src/flutter/testing/dart/channel_buffers_test.dart +++ b/engine/src/flutter/testing/dart/channel_buffers_test.dart @@ -49,6 +49,10 @@ void main() { final Completer completer = Completer(); scheduleMicrotask(() { log.add('before drain, microtask'); }); log.add('before drain'); + + // Ignoring the returned future because the completion of the drain is + // communicated using the `completer`. + // ignore: unawaited_futures buffers.drain(channel, (ByteData? drainedData, ui.PlatformMessageResponseCallback drainedCallback) async { log.add('callback'); completer.complete();