Skip to content
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(starturl): re-use already fetched manifest #6882

Closed
wants to merge 3 commits into from

Conversation

patrickhulce
Copy link
Collaborator

@patrickhulce patrickhulce commented Dec 28, 2018

Summary
We've talked about being able to reuse prior artifacts in other future gatherers but were always afraid of the precedence it sets for some horrifying graph of dependencies. This really is great use case though, so I wanted to play with it and see how it feels.

Therefore, I named the method dangerouslyUsePreviousArtifact in the hopes it assuages some concerns about this starting to be used everywhere 😆

Waiting to update start-url test depending on what kind of reaction this gets :)

Related Issues/PRs
fixes #6881

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

it's crazy but i'm into it. 👍

@@ -458,6 +469,16 @@ class GatherRunner {
passConfig,
// *pass() functions and gatherers can push to this warnings array.
LighthouseRunWarnings: baseArtifacts.LighthouseRunWarnings,
/** @param {keyof LH.GathererArtifacts} name */
async dangerouslyUsePreviousArtifact(name) {
Copy link
Member

Choose a reason for hiding this comment

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

feels like this fn should be defined outside of this for loop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what would be your preferred flavor?

dangerouslyUsePreviousArtifact: GatherRunner.dangerouslyUsePreviousArtifact.bind(gathererResults)
dangerouslyUsePreviousArtifact: GatherRunner.createPreviousArtifactFn(gathererResults)
dangerouslyUsePreviousArtifact(name) { return GatherRunner.dangerouslyUsePreviousArtifact(gathererResults, name); }

Copy link
Member

Choose a reason for hiding this comment

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

dangerouslyUsePreviousArtifact: GatherRunner.dangerouslyUsePreviousArtifact.bind(gathererResults)

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

ha, probably to no one's surprise, I'm not super into this :) but I think it's definitely worth thinking about.

We've had use cases before but never a super necessary one (they always end up "or we could do it this somewhat less convenient way"), but maybe this is it.

@patrickhulce
Copy link
Collaborator Author

We've had use cases before but never a super necessary one, but maybe this is it.

I do think #6881 presents the super necessary use case :D

@brendankenny
Copy link
Member

We've had use cases before but never a super necessary one, but maybe this is it.

I do think #6881 presents the super necessary use case :D

ha, sorry, I meant to say super necessary to share artifacts between gatherers instead of finding another solution. We definitely definitely should fix #6881 :) :)

@paulirish
Copy link
Member

DZL, do a barrel roll!

@devtools-bot
Copy link

DZL is done! Go check it out http://lh-dzl-6882.surge.sh

@patrickhulce
Copy link
Collaborator Author

@brendankenny what concretely does

I'm not super into this :) but I think it's definitely worth thinking about.

mean :)

Is it any of the following....?

  • I won't approve a PR that does this, but it's a starting point for a discussion on what to do.
  • I might approve a PR that does this, but I need 24 hours to think about it.
  • I would approve a PR that does this after I review it.

@brendankenny
Copy link
Member

Is it any of the following....?

My hesitation is that we already have a lot of implicit interactions in the gathering stage (online/offline, affects perf while a trace is being collected, etc), but at least the RequiredArtifacts system works well for figuring out the dependency graph when filtering audits and etc. Adding this method breaks that and it can only stay kind of broken or get worse from here :)

A couple of other options:

  • fix upstream (we didn't really look into what change caused Lighthouse unable to fetch manifest.json, favicons in Canary 73.0.3654.0 #6881. Something in Chrome's handling of manifests? Or a protocol change in relation to offline?)
  • work around (if the change was for a good reason, maybe there's a better way to do it)
  • treat manifests as special like Chrome does. Chrome fetches the manifest on the first visit to a site and has it available from a cache on future visits, even offline. We could do the same thing in LH, adding it to baseArtifacts when it's fetched, like finalUrl is updated.

I recognize the underlying issue that it's still vaguely reasonable to want to access artifacts between gatherers, but I think I favor the third option, since it lets us avoid that complexity and it matches how Chrome treats manifests as part of the meta information available for a site. I think we also have some help here, as I recently read that Chrome always fetches the manifest on first visit if a site has one, so we actually don't even need the driver.getAppManifest() call to get it out of the network traffic.

@patrickhulce
Copy link
Collaborator Author

We could do the same thing in LH, adding it to baseArtifacts when it's fetched, like finalUrl is updated.

I can get behind this 👍

@patrickhulce
Copy link
Collaborator Author

patrickhulce commented Jan 8, 2019

btw @brendankenny I skipped the first two because the bug has already been fixed a bit ago in Chrome :) Maybe not, see updated issue this is really just about making our starturl gatherer not refetch/reparse (and clumsily so it's currently susceptible to BOM issues for example)

I'll update the issue with a comment.

@brendankenny
Copy link
Member

btw @brendankenny I skipped the first two because the bug has already been fixed a bit ago in Chrome :)

oh, haha, whoops. I had no idea :)

@patrickhulce
Copy link
Collaborator Author

@brendankenny scratch that last thing I said, the author fixed the service worker and I attributed that to a 1-day Canary bug instead 😆 they will be sharing source code though so we can also get to bottom of it

@brendankenny
Copy link
Member

closing in favor of #6957

@brendankenny brendankenny deleted the reuse_manifest branch March 20, 2019 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lighthouse unable to fetch manifest.json, favicons in Canary 73.0.3654.0
4 participants