Bug 132928

Summary: Add image to cache
Product: WebKit Reporter: Martin Hock <mhock>
Component: WebCore Misc.Assignee: Martin Hock <mhock>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, commit-queue, japhet, psolanki
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch
ap: review+
API test
none
address comments ap: review+

Martin Hock
Reported 2014-05-14 16:06:22 PDT
Restore the call to add in MemoryCache::addImageToCache erroneously removed in r165117 and return the result. <rdar://problem/16651547>
Attachments
patch (1.21 KB, patch)
2014-05-14 16:10 PDT, Martin Hock
ap: review+
API test (8.85 KB, patch)
2014-05-15 14:35 PDT, Martin Hock
no flags
address comments (9.53 KB, patch)
2014-05-16 00:30 PDT, Martin Hock
ap: review+
Martin Hock
Comment 1 2014-05-14 16:10:24 PDT
Alexey Proskuryakov
Comment 2 2014-05-15 10:48:05 PDT
Comment on attachment 231470 [details] patch Is there any way to do a regression test for this fix?
Martin Hock
Comment 3 2014-05-15 11:02:47 PDT
I create(In reply to comment #2) > (From update of attachment 231470 [details]) > Is there any way to do a regression test for this fix? I created https://bugs.webkit.org/show_bug.cgi?id=132962 to track adding some unit tests to MemoryCache.
Martin Hock
Comment 4 2014-05-15 14:35:13 PDT
Created attachment 231535 [details] API test
Alexey Proskuryakov
Comment 5 2014-05-15 15:07:10 PDT
Comment on attachment 231535 [details] API test View in context: https://bugs.webkit.org/attachment.cgi?id=231535&action=review > Tools/TestWebKitAPI/Tests/Cocoa/MemoryCacheAddImageToCache.mm:34 > +#if TARGET_OS_IPHONE Would it be possible to create a separate directory for iOS tests, like we have for Mac ones? > Tools/TestWebKitAPI/Tests/Cocoa/MemoryCacheAddImageToCache.mm:35 > + CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); This looks like it leaks. > Tools/TestWebKitAPI/Tests/Cocoa/MemoryCacheAddImageToCache.mm:39 > + NSURL* url = [NSURL URLWithString:@"about:blank"]; Misplaced star.
Pratik Solanki
Comment 6 2014-05-15 15:10:57 PDT
Comment on attachment 231535 [details] API test View in context: https://bugs.webkit.org/attachment.cgi?id=231535&action=review This is great! Thanks for adding this test. > Tools/TestWebKitAPI/Tests/Cocoa/MemoryCacheAddImageToCache.mm:41 > + EXPECT_TRUE([WebCache imageForURL:url] == image); Let's test removeImageFrom cache as well. Something like this perhaps [WebCache removeImageFromCacheForURL:url]; EXPECT_TRUE([WebCache imageForURL:url] == 0);
Martin Hock
Comment 7 2014-05-15 19:34:25 PDT
(In reply to comment #6) > (From update of attachment 231535 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=231535&action=review > > This is great! Thanks for adding this test. > > > Tools/TestWebKitAPI/Tests/Cocoa/MemoryCacheAddImageToCache.mm:41 > > + EXPECT_TRUE([WebCache imageForURL:url] == image); > > Let's test removeImageFrom cache as well. Something like this perhaps > > [WebCache removeImageFromCacheForURL:url]; > EXPECT_TRUE([WebCache imageForURL:url] == 0); Actually, it turns out that removeImageFromCache doesn't immediately remove the image from the cache since it's manually cached. See the following comment: // Removing the last client of a CachedImage turns the resource // into a dead resource which will eventually be evicted when // dead resources are pruned. That might be immediately since // removing the last client triggers a MemoryCache::prune, so the // resource may be deleted after this call. But since the MemoryCache is not full, prune does nothing.
Pratik Solanki
Comment 8 2014-05-16 00:12:16 PDT
(In reply to comment #7) > (In reply to comment #6) > > (From update of attachment 231535 [details] [details]) > > View in context: https://bugs.webkit.org/attachment.cgi?id=231535&action=review > > > > This is great! Thanks for adding this test. > > > > > Tools/TestWebKitAPI/Tests/Cocoa/MemoryCacheAddImageToCache.mm:41 > > > + EXPECT_TRUE([WebCache imageForURL:url] == image); > > > > Let's test removeImageFrom cache as well. Something like this perhaps > > > > [WebCache removeImageFromCacheForURL:url]; > > EXPECT_TRUE([WebCache imageForURL:url] == 0); > > Actually, it turns out that removeImageFromCache doesn't immediately remove the image from the cache since it's manually cached. See the following comment: Thanks for the explanation. I think your test is fine in that case.
Martin Hock
Comment 9 2014-05-16 00:30:05 PDT
Created attachment 231561 [details] address comments
Martin Hock
Comment 10 2014-05-16 00:33:08 PDT
(In reply to comment #5) > (From update of attachment 231535 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=231535&action=review > > > Tools/TestWebKitAPI/Tests/Cocoa/MemoryCacheAddImageToCache.mm:34 > > +#if TARGET_OS_IPHONE > > Would it be possible to create a separate directory for iOS tests, like we have for Mac ones? I created an "ios" directory. There already was a similar directory at another level of the project, so I followed the pattern it established of ending the filename in IOS. > > Tools/TestWebKitAPI/Tests/Cocoa/MemoryCacheAddImageToCache.mm:35 > > + CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB(); > > This looks like it leaks. Fixed (along with the other leaks). > > Tools/TestWebKitAPI/Tests/Cocoa/MemoryCacheAddImageToCache.mm:39 > > + NSURL* url = [NSURL URLWithString:@"about:blank"]; > > Misplaced star. Fixed.
Martin Hock
Comment 11 2014-05-16 10:07:55 PDT
Note You need to log in before you can comment on or make changes to this bug.