Closed Bug 792735 Opened 12 years ago Closed 12 years ago

Remove synchronous calls to nsICacheSession::openCacheEntry in SeaMonkey

Categories

(SeaMonkey :: General, defect)

defect
Not set
normal

Tracking

(seamonkey2.14 fixed, seamonkey2.15 fixed, seamonkey2.16 fixed)

RESOLVED FIXED
seamonkey2.17
Tracking Status
seamonkey2.14 --- fixed
seamonkey2.15 --- fixed
seamonkey2.16 --- fixed

People

(Reporter: philip.chee, Assigned: neil)

References

Details

Attachments

(6 files, 3 obsolete files)

      No description provided.
References:
Bug 695399 - Remove synchronous calls to nsICacheSession::openCacheEntry in pageInfo.js
Bug 695399 - Remove calls to nsICacheSession::openCacheEntry on the main thread
Bug 737615 - Remove use of synchronous cache API from unit tests.
Depends on: 695399, 737615
I looked at metadata.js and I think it can be simplified because images never get stored in the FTP cache. I haven't looked at any of the other uses though.
Attached patch Possible patch for metadata.js (deleted) — Splinter Review
For metadata.js only. I also added a placeholder string to metadata.xul/dtd but this is optional. I had also considered renaming imageSizeUnknown to imageSizeNotCached and then adding the placeholder in script instead.
Attachment #663154 - Flags: review?(iann_bugzilla)
Attachment #663154 - Flags: review?(iann_bugzilla) → review+
Attached patch WIP (obsolete) (deleted) — Splinter Review
This is for page info but I'm not 100% sure about the image preview yet.
Attached patch Pr (obsolete) (deleted) — Splinter Review
Attached patch Proposed patch (obsolete) (deleted) — Splinter Review
* Converts reading the document size to using asyncOpenCacheEntry. I check both caches although we very rarely use the FTP cache. Note that the page size will briefly show as "Not specified" until the cache entry is opened.
* Creates a cache listener class for reading the cache entries for the media on the page, although I call it imageCacheListener for hysterical raisins.
* Fetches the cache entry device ID while reading the image size so that it can be used later for the image preview.
Assignee: nobody → neil
Attachment #669270 - Attachment is obsolete: true
Attachment #669276 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #669283 - Flags: review?(iann_bugzilla)
Comment on attachment 669283 [details] [diff] [review]
Proposed patch

>+function addImage(url, type, alt, elem, isBg)
>+{
>+  if (url) try {
>+    var listener = new imageCacheListener(url, type, alt, elem, isBg);
>+    httpCacheSession.asyncOpenCacheEntry(url, ACCESS_READ, listener);
>+  }
>+  catch (ex) { }
>+}
Don't need to try ftp here?

> function makePreview(row)
> {
>+  var [url, type, sizeText, alt, count, item, isBG, pageSize, deviceID] = gImageView.data[row];
[Snip]
> 
>   // find out the file size
>   var sizeText;
>+  if (pageSize) {
>     var kbSize = Math.round(pageSize / 1024 * 100) / 100;
>     sizeText = gBundle.getFormattedString("generalSize",
>                                           [formatNumber(kbSize),
>                                            formatNumber(pageSize)]);
>   }
>   setItemValue("imagesizetext", sizeText);
Don't we already know what sizeText is from gImageView.data[row]?

r=me with those addressed/fixed.
Attachment #669283 - Flags: review?(iann_bugzilla) → review+
(In reply to Ian Neal from comment #8)
> (From update of attachment 669283 [details] [diff] [review])
> >+function addImage(url, type, alt, elem, isBg)
> Don't need to try ftp here?
No, apparently we never cache FTP images. In fact as far as I can tell we only ever cache XUL FTP directory listings.

> >   setItemValue("imagesizetext", sizeText);
> Don't we already know what sizeText is from gImageView.data[row]?
That's formatted using the "mediaFileSize" string; we want the "generalSize" string here.
Comment on attachment 669283 [details] [diff] [review]
Proposed patch

> function makePreview(row)
> {
>+  var [url, type, sizeText, alt, count, item, isBG, pageSize, deviceID] = gImageView.data[row];
[Snip]

>   // find out the file size
>   var sizeText;
Presumably we don't need to re-declare sizeText?
Attached patch Proposed patch (tabbrowser) (deleted) — Splinter Review
This fixes tabbrowser.xml by switching to the favicon service.

Someone else must already be calling QI on the favicon service but I added it just to be sure.
Attachment #671239 - Flags: review?(iann_bugzilla)
Attached patch Fixed patch (pageInfo) (deleted) — Splinter Review
Attachment 669283 [details] [diff] didn't compute the image type correctly for background images. This version fixes that. I also updated the patch as per comment #10.
Attachment #669283 - Attachment is obsolete: true
Attachment #671248 - Flags: review?(iann_bugzilla)
Attachment #671248 - Flags: review?(iann_bugzilla) → review+
Attachment #663154 - Attachment description: Possible patch → Possible patch for metadata.js
Attachment #671248 - Attachment description: Fixed patch → Fixed patch (pageInfo)
Attachment #671239 - Attachment description: Proposed patch → Proposed patch (tabbrowser)
Comment on attachment 671248 [details] [diff] [review]
Fixed patch (pageInfo)

After applying this patch I tested it with the test case from
Bug 801930 - Exception in makePreview (pageinfo.js) (imgIRequest.image NS_ERROR_FAILURE)

And indeed I got the same error:
Tue Oct 16 2012 21:21:54
Error: NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [imgIRequest.image]
Source file: chrome://navigator/content/pageinfo/pageInfo.js
Line: 1246
>   var numFrames = 0;
I think we might have to get rid of this as well due to Bug 713889.
(In reply to Philip Chee from comment #14)
> >   var numFrames = 0;
> I think we might have to get rid of this as well due to Bug 713889.
This involves a string change so I would be better off doing it in a separate bug.
Attachment #671239 - Flags: review?(iann_bugzilla) → review+
Attached patch Branch-safe version (deleted) — Splinter Review
[Approval Request Comment]
Regression caused by (bug #): 695399
User impact if declined: Page Info claims no images are cached. Properties unable to display image sizes. Tabbrowser keeps trying to load missing favicons.
Testing completed (on m-c, etc.): 
Risk to taking this patch (and alternatives if risky):
String changes made by this patch: Removed for branch-safe version
Attachment #674386 - Flags: review+
Attachment #674386 - Flags: approval-comm-beta?
Attachment #674386 - Flags: approval-comm-aurora?
Attachment #674386 - Flags: approval-comm-beta?
Attachment #674386 - Flags: approval-comm-beta+
Attachment #674386 - Flags: approval-comm-aurora?
Attachment #674386 - Flags: approval-comm-aurora+
By the way the patch needs a bit of fuzz to apply on beta because of harmless changes in context lines.
Pushed comm-central changeset 2ca434d7cccd6.
https://hg.mozilla.org/releases/comm-aurora/rev/6c13bbdb2fff
https://hg.mozilla.org/releases/comm-beta/rev/ec317af35d42
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
> Pushed comm-central changeset 2ca434d7cccd6.
This should be: comm-central changeset 2ca434d7ccd6
Depends on: 804972
Attached patch Followup fix (deleted) — Splinter Review
Oops, I thought I had tested this, but I noticed that I forgot that aURI was a string and I need to convert it (as per loadFavIcon).
Attachment #675873 - Flags: review?(iann_bugzilla)
Depends on: 806144
Comment on attachment 675873 [details] [diff] [review]
Followup fix

[Triage Comment]
As other patches landed on comm-aurora/beta a/r=me
Attachment #675873 - Flags: review?(iann_bugzilla)
Attachment #675873 - Flags: review+
Attachment #675873 - Flags: approval-comm-beta+
Attachment #675873 - Flags: approval-comm-aurora+
Attached patch Third time lucky... (deleted) — Splinter Review
Attachment #692024 - Flags: review?
Attachment #692024 - Flags: approval-comm-beta?
Attachment #692024 - Flags: approval-comm-aurora?
Attachment #692024 - Flags: review?
Attachment #692024 - Flags: review+
Attachment #692024 - Flags: approval-comm-beta?
Attachment #692024 - Flags: approval-comm-beta+
Attachment #692024 - Flags: approval-comm-aurora?
Attachment #692024 - Flags: approval-comm-aurora+
Comment on attachment 692024 [details] [diff] [review]
Third time lucky...

Pushed comm-central changeset edb9f86b87da.
Target Milestone: --- → seamonkey2.17
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: