Sync async2#17964
Conversation
There was a problem hiding this comment.
The Flutter format for TODOs:
// TODO(username): Some explanation. See http://link/to/a/bug/123There was a problem hiding this comment.
| void handleDrawFrame() { | ||
| // Don't run this function when `handleBeginFrame` wasn't invoked | ||
| // immediately before. | ||
| // TODO(17963): Remove this line. |
This reverts commit 3ced55a.
| // immediately before without a call of `handleDrawFrame` in between. | ||
| // TODO(floitsch): Remove this line when the spurious calls from the | ||
| // framework don't happen anymore. See | ||
| // https://github.com/flutter/flutter/issues/17963 |
There was a problem hiding this comment.
I would rather we didn't check in this workaround and instead figured out what was going on and resolved that. This is very low-level code and not fully understanding what's going on here is likely to mean there are unexpected and extremely hard to debug bugs which our users are going to run into.
There was a problem hiding this comment.
For the record, the underlying issue is present and consistently causing assertion errors during test runs also without sync-async semantics. See e.g. this log for a microbenchmarks run upon landing b6ceff5:
[ +4 ms] Connected to Moto G 4
[ ] An Observatory debugger and profiler on Moto G 4 is available at http://127.0.0.1:8100/
[ ] For a more detailed help message, press "h". To quit, press "q".
[+3098 ms] I/flutter (14203): (The following exception is now available via WidgetTester.takeException:)
[ +3 ms] I/flutter (14203): ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
[ ] I/flutter (14203): The following assertion was thrown running a test:
[ ] I/flutter (14203): Failed assertion: boolean expression must not be null
[ ] I/flutter (14203):
[ ] I/flutter (14203): Either the assertion indicates an error in the framework itself, or we should provide substantially
[ ] I/flutter (14203): more information in this error message to help you determine and fix the underlying cause.
[ ] I/flutter (14203): In either case, please report this assertion by filing a bug on GitHub:
[ ] I/flutter (14203): https://github.com/flutter/flutter/issues/new
[ ] I/flutter (14203):
[ ] I/flutter (14203): When the exception was thrown, this was the stack:
[ ] I/flutter (14203): #0 LiveTestWidgetsFlutterBinding.handleDrawFrame (package:flutter_test/src/binding.dart:0)
[ ] I/flutter (14203): #1 _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842)
[ ] I/flutter (14203): #2 main.. (file:///Users/flutter/.cocoon/flutter/dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart:51)
[ ] I/flutter (14203): #11 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382)
[ ] I/flutter (14203): #12 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416)
[ ] I/flutter (14203): #13 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165)
[ ] I/flutter (14203): (elided 8 frames from package dart:async)
[ ] I/flutter (14203):
[ ] I/flutter (14203):
[ ] I/flutter (14203): ════════════════════════════════════════════════════════════════════════════════════════════════════
[ ] I/flutter (14203): (If WidgetTester.takeException is called, the above exception will be ignored. If it is not, then the above exception will be dumped when another exception is caught by the framework or when the test ends, whichever happens first, and then the test will fail due to having not caught or expected the exception.)
[ ] I/flutter (14203): ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
[ ] I/flutter (14203): The following assertion was thrown running a test:
[ ] I/flutter (14203): Failed assertion: boolean expression must not be null
[ ] I/flutter (14203):
[ ] I/flutter (14203): Either the assertion indicates an error in the framework itself, or we should provide substantially
[ ] I/flutter (14203): more information in this error message to help you determine and fix the underlying cause.
[ ] I/flutter (14203): In either case, please report this assertion by filing a bug on GitHub:
[ ] I/flutter (14203): https://github.com/flutter/flutter/issues/new
[ ] I/flutter (14203):
[ ] I/flutter (14203): When the exception was thrown, this was the stack:
[ ] I/flutter (14203): #0 LiveTestWidgetsFlutterBinding.handleDrawFrame (package:flutter_test/src/binding.dart:0)
[ ] I/flutter (14203): #1 _TestWidgetsFlutterBinding&BindingBase&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842)
[ ] I/flutter (14203): #2 main.. (file:///Users/flutter/.cocoon/flutter/dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart:51)
[ ] I/flutter (14203): #11 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382)
[ ] I/flutter (14203): #12 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416)
[ ] I/flutter (14203): #13 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165)
[ ] I/flutter (14203): (elided 8 frames from package dart:async)
[ ] I/flutter (14203):
[ ] I/flutter (14203):
[ ] I/flutter (14203): ════════════════════════════════════════════════════════════════════════════════════════════════════
[ ] E/flutter (14203): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
[ ] E/flutter (14203): Test failed. See exception logs above.
[ ] I/flutter (14203): ================ RESULTS ================
[ ] I/flutter (14203): :::JSON::: {"stock_layout_iteration":5645.528205128205}
[ ] I/flutter (14203): ================ FORMATTED ==============
Running lib/stocks/build_bench.dart
There was a problem hiding this comment.
It's not the same stack trace, and the fix was submitted 6 days ago. @mravn-google presumably you saw this error against a more recent commit than 6-days-old?
There was a problem hiding this comment.
| // framework don't happen anymore. See | ||
| // https://github.com/flutter/flutter/issues/17963 | ||
| if (_doDrawThisFrame == null) | ||
| return; |
| // When the test had an exception, the test-framework already | ||
| // ran the teardown functions, removing the _fakeAsync function. | ||
| if (_fakeAsync == null) | ||
| return null; |
There was a problem hiding this comment.
Is this really the cleanest way to solve this? I would hope that a refactor could find a much cleaner solution to this problem.
|
I would rather this was reverted and better fixes found. This seems like it just adds even more complexity to an already difficult to understand part of the codebase. |
This reverts commit 3ced55a.

Enables --sync-async for Flutter.
Fixes #16801.