Bug 131193

Summary: Web Replay: detect possible replay divergence from unexpected DOM event dispatches
Product: WebKit Reporter: Brian Burg <burg>
Component: WebCore Misc.Assignee: Brian Burg <burg>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, joepeck, kling, timothy
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 131281    
Bug Blocks:    
Attachments:
Description Flags
the patch none

Description Brian Burg 2014-04-03 17:02:20 PDT
We can assert the following invariant to find divergences:

If a DOM event is dispatched and the page's EventLoopInputDispatcher::dispatching() is false, then replay divergence is possible.

Let's unpack that:

1. For a web page's JS to execute deterministically, the engine must execute code blocks in the same order.
2. To run JS in the same order, DOM events must be dispatched in the same order.
3. For DOM events to be dispatched in the same order, the relevant run loops must be dispatched in the same order.
4. If we are not controlling the dispatch of a run loop that fired a DOM event, then it could potentially execute script in any order with respect to other run loops.

In practice, this assertion finds more nondeterminism (and provides useful stack traces) than any other technique.
In the short term, it will make it really hard to do replay in debug mode without asserting, so it should probably be put behind a guard that is normally compiled out. Once an error reporting mechanism is implemented, it could show a warning in the inspector UI.
Comment 1 Brian Burg 2014-04-06 18:58:07 PDT
Created attachment 228713 [details]
the patch
Comment 2 Andreas Kling 2014-04-07 10:14:38 PDT
Comment on attachment 228713 [details]
the patch

r=me
Comment 3 WebKit Commit Bot 2014-04-07 12:58:33 PDT
Comment on attachment 228713 [details]
the patch

Clearing flags on attachment: 228713

Committed r166880: <http://trac.webkit.org/changeset/166880>
Comment 4 WebKit Commit Bot 2014-04-07 12:58:36 PDT
All reviewed patches have been landed.  Closing bug.