-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: use flatten protocol #9783
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very fast @connorjclark nice work! 💨
This should not merge until the Chromium changes are ready.
The Chromium changes in that CL look like they include an LH roll, is that a circularish dependency? They also seem frontend only, does that mean that the bug...
DevTools crashes the renderer process when the mobile emulation Lighthouse applies is reverted. This happens even with just the LH bundle changes (no other devtools frontend changes).
will need to be fixed by a separate CL?
Basically, what should we reviewers do for you now? :)
@@ -40,7 +40,7 @@ class ResponseCompression extends Gatherer { | |||
const unoptimizedResponses = []; | |||
|
|||
networkRecords.forEach(record => { | |||
// Ignore records from OOPIFs | |||
// Ignore records from child targets (OOPIFS). | |||
if (record.sessionId) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requests from the main target still won't have a sessionId
will they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
Thanks :)
I mean we shouldn't land this in LH until we fix the crashing bug in DevTools. Otherwise, we won't be able to release to DevTools. The CL doesn't have to land first.
We should have a fix ready to go before landing any of this.
Mostly, we should start bike-shedding the necessary interface changes to Any idea why the crash is happening? That's what I'm up to today. |
Update on this. This is unrelated to these changes. Can be repro'd by merging master LH into ToT Chromium. AFAICT, an additional Session/EmulationHandler.cc is sending an extra some logging I found helpful, for later.
|
It's #9377. yay...I solved it? :/ Let's merge this plz. |
Must merge #9193 first. Flatten won't work with the extension. |
These changes won't work with M77 (see failing oopif smoke test). I don't know why. We don't really need it to (78 comes |
Only DevTools change: https://chromium.googlesource.com/chromium/src/+/001ceaaaa92cf3dbfa573fb40c3a682e0dc72fd7 This is what fixed the issue. Snippet from CL:
Bisect command:
|
So here are the pertinent dates and constraints: Oct 15: M78 stable release. To avoid breaking master LH on Stable Chrome, must land this PR after this date. Also Oct 15: scheduled LH release. Oct 17: M79 branch. To fix auditing OOPIFs in the Audits panel, must land this PR and the associated Chromium CL by this date (plus, roll LH). This is a soft deadline - we can probably get a merge OK'd a bit after easily enough. Removing Draft status, since the big two issues have been addressed. PTAL |
See #9783 (comment) and the two comments following. These changes won't work in CI until the new stable release tomorrow.
The Chromium change has been merged already. |
Co-Authored-By: Patrick Hulce <patrick.hulce@gmail.com>
LGTM from me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright LGTM assuming we can get a green build out of the new stable :)
* @param {boolean} enable | ||
* @return {boolean} | ||
* @private | ||
*/ | ||
_shouldToggleDomain(domain, enable) { | ||
const enabledCount = this._domainEnabledCounts.get(domain) || 0; | ||
_shouldToggleDomain(domain, sessionId, enable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time to add tests for this functionality? :D
should hopefully be pretty easy with the new mock capabilities and can just sendCommand('Network.enable')
or whatever to make sure it doesn't turn off to early :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time to add tests for this functionality? :D
should hopefully be pretty easy with the new mock capabilities and can just
sendCommand('Network.enable')
or whatever to make sure it doesn't turn off to early :)
+1 to this. After a certain number of enables and disables, watching when the actual command is sent shouldn't end up too bad, I hope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM3 with an extra test or two
Nice and neat and great to be able to delete a good chunk of code
lighthouse-core/gather/gatherers/dobetterweb/optimized-images.js
Outdated
Show resolved
Hide resolved
}); | ||
}); | ||
|
||
it('enables the Network domain for iframes of iframes of iframes', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was the earlier discussions about tests about this? It seems a shame to lose this assertion (and we still have to make sure to recursively enable attaching, so could still conceivably be broken at some point)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path for attaching to an iframe target is now the exact same as attaching to an iframe's iframe target, so I don't see functionality in having a test for this. I removed the test because it needed to be rewritten to continue working, and how to do so was a head-scratcher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path for attaching to an iframe target is now the exact same as attaching to an iframe's iframe target, so I don't see functionality in having a test for this.
one level deep appears to be in gotoURL
while 2+ levels deep appears to happen in _handleTargetAttached
, I believe?
@patrickhulce could maybe help make the call/give an idea for testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goToURL calls Target.setAutoAttach
on the main target, but the first and subsequent targets will be via _handleTargetAttached
. I suppose it was this way before too, but what's different now is that we don't have to worry about the complicated message routing - I believe this test existed just to verify that mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it's having a test of the inductive step that would feel good, even if it's a trivial difference from the initial attachment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
though I guess what you may be saying is that since we don't keep any hierarchy of the child targets (e.g. looking at openerId
), having a child target of a child target is indistinguishable from having two sibling child targets in terms of protocol traffic we'd care about.
That's a good point and that means the second one is a really trivial difference from the first, but it seems ok to include a two-child-target case, which would also provide a nice tripwire/starting point if and when we ever start treating fourth-party, etc content differently and need to track the target hierarchy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mostly lean on @connorjclark's side of this that there is no difference to driver in this case now and we're basically relying on chrome to do the right thing and send us nested targets, mocking Chrome doing the right thing doesn't feel super valuable since it ends up being indistinguishable to us
I feel comfortable enough with the grandchild OOPIF smoke test we have that exercises this, but a two-child-target test case seems reasonable as the test for this anyhow, so might as well :)
* @param {boolean} enable | ||
* @return {boolean} | ||
* @private | ||
*/ | ||
_shouldToggleDomain(domain, enable) { | ||
const enabledCount = this._domainEnabledCounts.get(domain) || 0; | ||
_shouldToggleDomain(domain, sessionId, enable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time to add tests for this functionality? :D
should hopefully be pretty easy with the new mock capabilities and can just
sendCommand('Network.enable')
or whatever to make sure it doesn't turn off to early :)
+1 to this. After a certain number of enables and disables, watching when the actual command is sent shouldn't end up too bad, I hope.
Also cherry-picked: GoogleChrome/lighthouse#9377 GoogleChrome/lighthouse#9783 Bug: 772558 Bug: 1011228 Change-Id: Ibe9e4b3849940bf86c666bf55698a9ced4253fd3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1867249 Reviewed-by: Erik Luo <luoe@chromium.org> Commit-Queue: Connor Clark <cjamcl@google.com> Cr-Original-Commit-Position: refs/heads/master@{#707110} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 5f16f693662c78467b8ae531a3f03e37ccf94c69
Also cherry-picked: GoogleChrome/lighthouse#9377 GoogleChrome/lighthouse#9783 Bug: 772558 Bug: 1011228 Change-Id: Ibe9e4b3849940bf86c666bf55698a9ced4253fd3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1867249 Reviewed-by: Erik Luo <luoe@chromium.org> Commit-Queue: Connor Clark <cjamcl@google.com> Cr-Commit-Position: refs/heads/master@{#707110}
Should start passing tomorrow :) |
This needs to land, or else it becomes the second PR that needs to be merged to releases for DevTools to work (the first being #9377) |
I see two official LGTMs and a third unofficial one, so... :P |
Chromium CL
We need to migrate to the flatten protocol for a few reasons:
Target.sendMessageToTarget
/Target.receivedMessageFromTarget
is a waste of bandwidth and processing time.For this initial pass, I created a new
sendCommandToSession
method so the ~200 usages ofsendCommand
don't need to change. Could split out the very common code betweensendCommand
/sendCommandToSession
, but I don't think we combine it into one interface (the rest params make an optional parameter impossible).Open problems:
The oopif smoke fixture seems to take a few seconds longer. Why?
DevTools crashes the renderer process when the mobile emulation Lighthouse applies is reverted. This happens even with just the LH bundle changes (no other devtools frontend changes).
I left some useful debugging code commented out. Will remove after these open problems are resolved.
Timings:
https://gist.githubusercontent.com/connorjclark/b6ed524cfd9cbead8186e219a0f74f59/raw/a089d238eb166ff3954ba7918f61736effcbb664/gistfile1.txt