Bug 130865 - Web Replay: Move createUniqueIdentifier() from ProgressTracker to DocumentLoader
Summary: Web Replay: Move createUniqueIdentifier() from ProgressTracker to DocumentLoader
Status: RESOLVED LATER
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Major
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 129391
  Show dependency treegraph
 
Reported: 2014-03-27 15:04 PDT by BJ Burg
Modified: 2017-07-10 13:59 PDT (History)
8 users (show)

See Also:


Attachments
the patch (14.96 KB, patch)
2014-03-27 17:44 PDT, BJ Burg
no flags Details | Formatted Diff | Diff
Patch (16.18 KB, patch)
2014-03-29 13:02 PDT, Brian Burg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description BJ Burg 2014-03-27 15:04:42 PDT
That way, it will be possible later to track on a per-frame level the order in which identifiers were handed out.
Comment 1 BJ Burg 2014-03-27 17:44:24 PDT
Created attachment 228011 [details]
the patch
Comment 2 Brady Eidson 2014-03-27 21:07:43 PDT
(In reply to comment #0)
> That way, it will be possible later to track on a per-frame level the order in which identifiers were handed out.

How will it be possible?

What will this accomplish?

I'm not sure DocumentLoader is the right place for this.
Comment 3 Brian Burg 2014-03-29 10:43:50 PDT
Per discussion with Brady, we concluded that it's better architecture for the main frame's document loader to vend unique identifiers. That way there is only one vendor per frame tree, and thus for 129391 we'll only need to save one identifier order vector.

I'm going to upload another patch with this alternate arrangement, then rebase a patch for 129391 and test that before setting r?.
Comment 4 Brian Burg 2014-03-29 13:02:21 PDT
Created attachment 228115 [details]
Patch
Comment 5 Timothy Hatcher 2014-03-29 13:07:43 PDT
Comment on attachment 228115 [details]
Patch

Looks fine to me. I'll let Brady look it over.
Comment 6 Brian Burg 2014-03-29 13:09:48 PDT
I haven't posted a new patch for 129391 yet, that will be up later tonight or tomorrow.
Comment 7 Brian Burg 2014-03-30 23:02:14 PDT
(In reply to comment #6)
> I haven't posted a new patch for 129391 yet, that will be up later tonight or tomorrow.

Other patch is up, so this thing is ready for review.
Comment 8 Brian Burg 2014-04-17 11:06:27 PDT
Can anyone review this?
Comment 9 Darin Adler 2014-04-17 11:38:20 PDT
This is inelegant.

Going to the main frame’s document loader each time is super-awkward. Adding something to all document loaders that is only used for main frame document loaders is a bad pattern that we should not do more of.

Is there anything we can do to make the idiom clearer and not involve so much reliance on traversing pointers that might be null?
Comment 10 Brian Burg 2014-04-17 16:39:51 PDT
(In reply to comment #9)
> This is inelegant.
> 
> Going to the main frame’s document loader each time is super-awkward. Adding something to all document loaders that is only used for main frame document loaders is a bad pattern that we should not do more of.
> 
> Is there anything we can do to make the idiom clearer and not involve so much reliance on traversing pointers that might be null?

I don't see a way to make this more elegant without adding a new abstraction.

Last month I heard that some folks had the desire to add an abstraction to represent the "current page", and that such a class would get new instances on main frame navigations. Every document and frame and loader would have a reference to the "current page", like MainFrame, but with more integration with navigation somehow. I don't know enough about the big picture to write a patch for that abstraction.

This hypothetical class is where vending and tracking of per-main frame resource identifiers should go, but I don't think anyone has had time to work on that refactoring.  I would prefer to add FIXMEs and open a new bug for adding that abstraction and develop that idea separately, rather than gating this smaller refactor (and the remainder of web replay patches that depend on network replay).
Comment 11 Brady Eidson 2014-04-17 16:52:10 PDT
(In reply to comment #10)
> (In reply to comment #9)
> > This is inelegant.
> > 
> > Going to the main frame’s document loader each time is super-awkward. Adding something to all document loaders that is only used for main frame document loaders is a bad pattern that we should not do more of.
> > 
> > Is there anything we can do to make the idiom clearer and not involve so much reliance on traversing pointers that might be null?
> 
> I don't see a way to make this more elegant without adding a new abstraction.
> 
> Last month I heard that some folks had the desire to add an abstraction to represent the "current page", and that such a class would get new instances on main frame navigations

It would actually get new instances on any navigation, including subframe navigations.

So you'd always have a non-null MainFrame, and you could always ask it for "current page".

>  Every document and frame and loader would have a reference to the "current page", like MainFrame, but with more integration with navigation somehow.

Not really - Every document and frame and loader has a path to their MainFrame, who is the sole keeper of "the current page"

> This hypothetical class is where vending and tracking of per-main frame resource identifiers should go, but I don't think anyone has had time to work on that refactoring.  I would prefer to add FIXMEs and open a new bug for adding that abstraction and develop that idea separately, rather than gating this smaller refactor (and the remainder of web replay patches that depend on network replay).

Don't vending of per-MainFrame resource IDs belong on the MainFrame itself?
Comment 12 Brian Burg 2014-04-17 17:24:50 PDT
(In reply to comment #11)
> (In reply to comment #10)
> It would actually get new instances on any navigation, including subframe navigations.
> ...
> So you'd always have a non-null MainFrame, and you could always ask it for "current page".

I suppose it could be per-any-navigation. Though that level of granularity isn't needed for replay but is compatible.

> Not really - Every document and frame and loader has a path to their MainFrame, who is the sole keeper of "the current page"

Oh, true, we always go through MainFrame in the patch, as written.

> Don't vending of per-MainFrame resource IDs belong on the MainFrame itself?

Ah, I should have been more specific. For replay purposes, we need to be able to record what resource IDs were handed out on a per-main-frame-*navigation* basis.

The main benefit of using the main frame's document loader is that its lifetime is obvious and corresponds exactly to the "main frame navigation" boundary used to segment executions into independent replayable pieces when capturing.

Vending and recording IDs from MainFrame itself is more complicated.

1. MainFrame will stick around across multiple navigations, so we'd have to reach into it to clear out the recorded vended IDs when the main frame navigates.

2. It also will interleave IDs vended to requests from the main frame's provisional and active document loaders, but the two loaders are not necessarily both being captured or replayed. If we start capturing the next main frame navigation and a resource request is created when the old main frame is unloaded, then the vended ID for the request will be mistakenly captured. 

3. Disambiguation is hard without the natural segmenting provided by the lifetime of the main frame document loader. To disambiguate whether the ID should be captured or not, we need to look at a flag on the associated document's input cursor. AFAIK, we don't always have a document around when requesting a resource ID (e.g., on initial document resource request), so not sure how we could always disambiguate correctly.
Comment 13 BJ Burg 2015-08-05 11:30:06 PDT
Comment on attachment 228115 [details]
Patch

Clearing r? flag as this patch is bit-rotted.
Comment 14 BJ Burg 2017-07-10 13:59:34 PDT
Closing web replay-related bugs until we resume working on the feature again.