Bug 1363059 - Add a test for images loaded at startup vs. images shown at startup. r=florian,jwatt
This patch enables startupRecorder.js to collect data on loaded and shown raster and SVG images on startup via events from native code. It also adds a test that uses this data to find images that are unnecessarily loaded. I've not fixed any of the affected images yet, there's a fairly comprehensive whitelist that I want to gradually decrease by opening bugs in the respective components. MozReview-Commit-ID: 9KqQvKLtZhu
This commit is contained in:
@@ -92,6 +92,18 @@ ImageFactory::CreateImage(nsIRequest* aRequest,
|
||||
// Compute the image's initialization flags.
|
||||
uint32_t imageFlags = ComputeImageFlags(aURI, aMimeType, aIsMultiPart);
|
||||
|
||||
#ifdef DEBUG
|
||||
// Record the image load for startup performance testing.
|
||||
if (NS_IsMainThread()) {
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (NS_WARN_IF(obs)) {
|
||||
nsAutoCString spec;
|
||||
aURI->GetSpec(spec);
|
||||
obs->NotifyObservers(nullptr, "image-loading", NS_ConvertUTF8toUTF16(spec).get());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Select the type of image to create based on MIME type.
|
||||
if (aMimeType.EqualsLiteral(IMAGE_SVG_XML)) {
|
||||
return CreateVectorImage(aRequest, aProgressTracker, aMimeType,
|
||||
|
||||
Reference in New Issue
Block a user