Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Issue 36463002: Fix a synchrony bug in barback. (Closed)

Created:
7 years, 2 months ago by nweiz
Modified:
7 years, 1 month ago
CC:
reviews_dartlang.org, Bob Nystrom
Visibility:
Public.

Description

Fix a synchrony bug in barback. Barback was assuming that certain Future operations were synchronous when in fact they were not (issue 14323). This caused behavioral bugs in situations with high input churn. Specifically, barback would attempt to use the synchronous Future operations to guarantee that no changes happened between a condition being checked and that condition being reported to the user. Since the Future operations were not in fact synchronous, such changes were possible. This change works around the issue by using a manual callback-passing style in places where synchrony is important and Futures would otherwise be used. R=alanknight@google.com Committed: https://code.google.com/p/dart/source/detail?r=29103

Patch Set 1 #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+110 lines, -29 lines) Patch
M pkg/barback/lib/src/asset_node.dart View 3 chunks +25 lines, -19 lines 0 comments Download
M pkg/barback/lib/src/group_runner.dart View 1 chunk +1 line, -1 line 0 comments Download
M pkg/barback/lib/src/phase.dart View 1 chunk +1 line, -1 line 0 comments Download
M pkg/barback/lib/src/phase_input.dart View 1 chunk +11 lines, -6 lines 0 comments Download
M pkg/barback/lib/src/phase_output.dart View 1 chunk +1 line, -1 line 0 comments Download
M pkg/barback/lib/src/transform_node.dart View 1 chunk +1 line, -1 line 0 comments Download
A pkg/barback/test/package_graph/repetition_test.dart View 1 chunk +70 lines, -0 lines 6 comments Download

Messages

Total messages: 5 (0 generated)
nweiz
7 years, 2 months ago (2013-10-23 03:58:54 UTC) #1
Alan Knight
lgtm
7 years, 2 months ago (2013-10-23 16:30:18 UTC) #2
nweiz
Committed patchset #1 manually as r29103 (presubmit successful).
7 years, 2 months ago (2013-10-23 17:55:07 UTC) #3
Bob Nystrom
I don't understand this change. We almost always prefer futures over callbacks, so why refactor ...
7 years, 1 month ago (2013-10-28 16:51:30 UTC) #4
nweiz
7 years, 1 month ago (2013-10-28 23:54:49 UTC) #5
Message was sent while issue was closed.
It turns out there was never such a thing as a "synchronous future".
[Future.sync] only runs the callback synchronously; the behavior of the returned
future is identical to any other future. [Completer.sync] only synchronously
fires events that are registered prior to [Completer.complete] being called.
There's no way to create a future that will synchronously call a [then] callback
when it's registered. The dart:async folks don't seem interested in changing
this; see issue 14323.

I'd like to use Futures here; I even tried to implement a SyncFuture class to
get the behavior we intended and assumed. It didn't work, so I came to the
conclusion that the only clean way to do this is to accept that the only way to
cleanly handle potentially-synchronous callbacks is to manually dispatch them
the old-fashioned way.

https://codereview.chromium.org/36463002/diff/1/pkg/barback/test/package_grap...
File pkg/barback/test/package_graph/repetition_test.dart (right):

https://codereview.chromium.org/36463002/diff/1/pkg/barback/test/package_grap...
pkg/barback/test/package_graph/repetition_test.dart:12: main() {
On 2013/10/28 16:51:30, Bob Nystrom wrote:
> Can you add some documentation here explaining what this is stress testing and
> why?

Done.

https://codereview.chromium.org/36463002/diff/1/pkg/barback/test/package_grap...
pkg/barback/test/package_graph/repetition_test.dart:48: for (var i = 0; i < 1;
i++) {
On 2013/10/28 16:51:30, Bob Nystrom wrote:
> That's not very many times.

Oops, left over from debuggnig. Fixed.

https://codereview.chromium.org/36463002/diff/1/pkg/barback/test/package_grap...
pkg/barback/test/package_graph/repetition_test.dart:61: for (var i = 0; i < 1;
i++) {
On 2013/10/28 16:51:30, Bob Nystrom wrote:
> Ditto.

Done.

Powered by Google App Engine
This is Rietveld 408576698