Don't enforce wal checkpoints during Places startup, since that can possibly cause a deadlock that would
make some early synchronous API calls bailout. That would indeed cause unexpected intermittent failures
in tests.
Regardless, forcing checkpoints like this in modern filesystems is unlikely to add much value, since
the probabilities to lose the whole contents of the journal are very low.
Additionally we have better startup handling of invalid databases, so we should be able to recover in any case.
MozReview-Commit-ID: G7nISZkd8s2
Favicons migrated from the old store have expiration set to 0.
The code is not expecting that, since expiration has always been positive, thus
those icons are always considered valid and never replaced. They should instead be
considered expired.
MozReview-Commit-ID: Cz0JB4IbURA
Favicons migrated from the old store have expiration set to 0.
The code is not expecting that, since expiration has always been positive, thus
those icons are always considered valid and never replaced. They should instead be
considered expired.
MozReview-Commit-ID: Cz0JB4IbURA
Root domain icons are no more associated with their pages, BUT if the page uses
a root domain icon from another domain, it should still get an association with it
or we couldn't relate the two.
This also fixes an overlooked problem in PlacesTestUtils where Date objects
cross a boundary and fail instanceof checks. This causes failures in the same
test that this patch is modifying.
To protect from future similar issues some protection has been added to updatedPlaces
so that it will crash in debug builds.
MozReview-Commit-ID: 3MTKhGj3ehj
Root domain icons are no more associated with their pages, BUT if the page uses
a root domain icon from another domain, it should still get an association with it
or we couldn't relate the two.
This also fixes an overlooked problem in PlacesTestUtils where Date objects
cross a boundary and fail instanceof checks. This causes failures in the same
test that this patch is modifying.
To protect from future similar issues some protection has been added to updatedPlaces
so that it will crash in debug builds.
MozReview-Commit-ID: 3MTKhGj3ehj
Root domain icons should be retained as far as possible, and only expired when
a domain is removed from the database. We do that through the moz_hosts trigger.
Additionally, since we return root domain icons without the need for a direct
association, we can save a lot of database space and performance by not storing
associations at all for root domain icons.
This has some downsides, since we don't exactly know if the page was really
associated with that root icon or not, but the perf gains are far superior.
Note that we still create associations during migration, since it would be too
expensive to examine every single url to figure out if it's a root domain icon.
MozReview-Commit-ID: 3mlfcOV8ixC
When optimizing an ico file, split it into its single resources and pick only
the sizes we care about. This also de-dupes same size resources.
The migration path doesn't split ico files, since it's a performance hot path
and we should try to reduce the I/O load at that time. The worst case is that
some icons may not look that much crisp until the next page reload.
Note that while the "resource" naming would be more appropriate for ico files,
compared to "frame" that is more appropriate for animations, the patch still
uses the frame name, cause it's far less generic and can be more easily
associated with the concept of a graphical asset. Regardless, it's not exposed
in any public API.
MozReview-Commit-ID: 3vrGXzJDfjX
When an icon for a specific page is not available, try to fallback for the root
domain icon.
This is valid for both getFaviconUrlForPage and getFaviconDataforPage, as well
as the page-icon: protocol.
MozReview-Commit-ID: JC4cx1PAY38
Inserting new payloads for a page should expire old ones, otherwise if the page
should change favicons, we'd retain old associations forever.
At the same time, setting multiple payloads for a page should keep working.
MozReview-Commit-ID: 2y1XLUiKAQo
Updates consumers to the new behavior.
Some consumers are changed to use the "page-icon:" protocol, since it's not
trivial to join the icons table and get a single result out of it. In most cases
the join would return multiple results since a page can have multiple icon payloads.
These consumers for now will return the biggest payload, bug 1347532 will fix
some of them to properly pass a #size=NN fragment.
Note that, even before, these were just "moz-anno:favicon:" uris, and the
payload had to be fetched from the database.
Some other consumers for now just fallback to the largest payload, by passing 0
to GetFaviconURLForPage.
The favicon optimization still happens on the main-thread, bug 1346139 will
handle that problem.
Most of the changes involve handling the modified IconData objects, that now
retain an array of payloads, rather than just one. But note that .ico files are
not yet split into single frames, due to imagelib missing APIs that will be handled
in bug 1337402.
The other changes involve fixing queries to properly join with the new tables.
Finally, note that thanks to the FOREIGN KEYS support, removing from moz_icons or
moz_pages_w_icons will also remove relations from moz_icons_to_pages.
The system only supports square icons, so icons are resized based on their larger side.
This doesn't include new tests, those will be in a following changeset.
MozReview-Commit-ID: JUkpquhpS8y
This patch moves favicons blobs to a separate database names favicons.sqlite.
The dabatase is then ATTACHED to the main Places connection, so that its tables
can be used as if they were all part of the same database.
The favicons.database contains 3 tables:
1. moz_pages_w_icons
This is the way to join with moz_places, through page_url_hash and page_url.
We are not using the place id to avoid possible mismatches between places.sqlite
and favicons.sqlite. This way the database is "portable" and reusable even
if places.sqlite changes.
2. moz_icons
Contains icons payloads, each payload can either be an SVG or a PNG. These
are the only stored formats, any other format is rescaled and converted to
PNG. ICO files are split into single frames and stored as multiple PNGs.
SVG are distinguishable through width == UINT16_MAX
In future the table will also contain mask-icon color for SVG and average
color for PNGs.
The fixed_icon_url_hash is "fixed" to allow quickly fetch root icons, that
means icons like "domain/favicon.ico" that can also be reused for any page
under that domain.
3. moz_icons_to_pages
This is the relation table between icons and pages.
Each page can have multiple icons, each icon can be used by multiple pages.
There is a FOREIGN_KEY constraint between this (child) table and icons
or pages (parents), so that it's not possible to insert non-existing ids
in this table, and if an entry is removed from a parent table, the relation
will be automatically removed from here.
Note though that removing from the relation table won't remove from the
parent tables.
Since the relations are now many-many, it's no more possible to simply join
places with the icons table and obtain a single icon, thus it's suggested that
consumers go through the "page-icon" protocol.
The migration process from the old favicons table is async and interruptible,
it will be restarted along with the favicons service until the temp preference
places.favicons.convertPayloads is set to true.
MozReview-Commit-ID: CUCoL9smRyt