-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Bugfix FXIOS-9427 Fixes for favicon issues [WIP] #20991
Bugfix FXIOS-9427 Fixes for favicon issues [WIP] #20991
Conversation
while let currentSiteRequest = currentInFlightRequest, | ||
imageModel.siteURLString == currentSiteRequest { | ||
// We are already processing a favicon request for this site | ||
// Sleep this task until the previous request is completed | ||
try? await Task.sleep(nanoseconds: 50_000_000) // 50ms | ||
} |
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.
@OrlaM @nbhasin2 This isn't particularly elegant but it should fix the redundant requests both for the site HTML and favicons and is the simplest fix I could find that also didn't cause any other obvious regressions. If anyone has suggestions on a better solution, however, please LMK. Happy to sync up or chat further.
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.
Is the source of the problem that one SiteImageView is trying to request the favicon multiple times or that multiple SiteImageViews are fetching the same favicon?
If the former then at what point is the current solution that is supposed to catch this failing? It's supposed to check against the currentURLString before it even gets to the image handler.
If it's the later then this fix won't help because SiteImageHandler is created new for each SiteImageView.
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.
If the former then at what point is the current solution that is supposed to catch this failing? It's supposed to check against the currentURLString before it even gets to the image handler.
So this is a little bit more complicated than it seems, there is some code that is calling manuallySetImage repeatedly in the midst of also repeatedly updating the favicon to the same/identical URL. This results in the currentURLString
getting reset basically so while it still serves a valid purpose, unfortunately the way that we're (over-)refreshing things still breaks it and causes redundant requests to be fired off.
If it's the later then this fix won't help because SiteImageHandler is created new for each SiteImageView.
I've been testing this fairly exhaustively and if you put a breakpoint or log in the code which kicks off the network requests for the site HTML or the favicons, that code is called multiple times when first visiting a website, but with this change in place it is correctly only hit once (and subsequent requests wait until the original one is completed). LMK if you're seeing something different however and/or if you have steps that are still replicating the issue.
@@ -9,7 +9,7 @@ const metadataParser = require("page-metadata-parser/parser.js"); | |||
|
|||
function MetadataWrapper() { | |||
this.getMetadata = function() { | |||
let metadata = metadataParser.getMetadata(document, document.URL); | |||
let metadata = metadataParser.getMetadata(document, location.origin); |
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.
Note: this change was suggested by @issammani (ty), and is part of the fix for the incorrect favicon URLs, which are actually coming from two different places, one of which being the JS metadata parser.
Generated by 🚫 Danger Swift against 0ec1d78 |
…requests and invalid favicon URLs
71d92c5
to
07d16aa
Compare
(Note: the failing unit test |
I've done some additional regression/smoke testing on this branch and couldn't identify any issues so planning to merge shortly. But if anyone has follow-up feedback LMK and I'm happy to revisit. |
📜 Tickets
Jira ticket
Github issue
💡 Description
Early work to fix a couple problems with our favicon fetching. I'll be adding some notes inline, please also see forthcoming comments in PR diff.
This should resolve at least a couple problems with favicons:
📝 Checklist
You have to check all boxes before merging
@Mergifyio backport release/v120
)