Sync async2 by floitschG · Pull Request #17964 · flutter/flutter · GitHub
Skip to content

Sync async2#17964

Merged
floitschG merged 6 commits into
flutter:masterfrom
floitschG:sync_async2
May 28, 2018
Merged

Sync async2#17964
floitschG merged 6 commits into
flutter:masterfrom
floitschG:sync_async2

Conversation

@floitschG

@floitschG floitschG commented May 28, 2018

Copy link
Copy Markdown
Contributor

Enables --sync-async for Flutter.

Fixes #16801.

@mravn-google mravn-google left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Flutter format for TODOs:

// TODO(username): Some explanation. See http://link/to/a/bug/123

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

void handleDrawFrame() {
// Don't run this function when `handleBeginFrame` wasn't invoked
// immediately before.
// TODO(17963): Remove this line.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@mravn-google mravn-google left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@floitschG floitschG merged commit 3ced55a into flutter:master May 28, 2018
@floitschG floitschG deleted the sync_async2 branch May 28, 2018 14:21
mravn-google added a commit that referenced this pull request May 28, 2018
// 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the issue @tvolkert fixed recently?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// framework don't happen anymore. See
// https://github.com/flutter/flutter/issues/17963
if (_doDrawThisFrame == null)
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

// When the test had an exception, the test-framework already
// ran the teardown functions, removing the _fakeAsync function.
if (_fakeAsync == null)
return null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really the cleanest way to solve this? I would hope that a refactor could find a much cleaner solution to this problem.

@Hixie

Hixie commented May 28, 2018

Copy link
Copy Markdown
Contributor

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.

@tvolkert

Copy link
Copy Markdown
Contributor

Given @Hixie's comments and the fact that this has been implicated in #17989, I think we should revert this.

@mravn-google

Copy link
Copy Markdown
Contributor

mravn-google added a commit to mravn-google/flutter that referenced this pull request May 29, 2018
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make flutter_test work with sync-async semantics

5 participants