If you both prefetch a resource, and use it as a subresource, the second of these two fetches fails due to a type mismatch on the CachedResource.
See Also: http://code.google.com/p/chromium/issues/detail?id=61468
I think Eric might have just fixed this bug. Can you check if it still happens at top-of-tree?
I just tested with tip-of-tree, and I think Eric has not fixed this bug. :/
Created attachment 74952 [details]
Created attachment 74953 [details]
This is not my favourite fix ever. I think this works: the WebKit cache doesn't get subresources loaded into it, and so we rely on the disk cache from the network stack to be primed when doing prefetches.
I'd be happier if instead, we were letting the prefetch data into the memory cache, and then just either mutated the cache entry to a different type, or something like that, if a subresource request came.
Also, don't we have a bug if you use the same file as both an image and a JS file, or an image and a css file, etc..., in the same page? I suppose that's less significant than what I fixed though.
N.B.: I haven't added test exclusions for my new unit test, since it runs fine if you don't have link prefetch. The test only fails if you both have link prefetch enabled, and don't have this patch.
Comment on attachment 74953 [details]
View in context: https://bugs.webkit.org/attachment.cgi?id=74953&action=review
This seems fine. I wonder if we can avoid the CachedResouceLoader now that the ResourceLoadScheduler isn't tied so tightly to the MemoryCache...
> + setTimeout("layoutTestController.notifyDone()",500);
boo timeouts lead to flakiness.
Comment on attachment 74953 [details]
Rejecting patch 74953 from commit-queue.
Failed to run "['./WebKitTools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '--bot-id=eseidel-cq-sl', 'build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive']" exit_code: 2
Last 500 characters of output:
fast/dom/HTMLLinkElement/link-and-subresource-test.html -> failed
Exiting early after 1 failures. 7167 tests run.
152.91s total testing time
7166 test cases (99%) succeeded
1 test case (<1%) had incorrect layout
3 test cases (<1%) had stderr output
Full output: http://queues.webkit.org/results/6296083
Interesting: there's a failure here that I was not seeing in my testing on gtk, or my earlier testing on mac. I'm now investigating.
Created attachment 74976 [details]
This new upload fixes two mistakes I made
1. I have added my new tests to the skipped section. Yes, the tests when run manually look correct if you don't have prefetching, however the media list is different, since of course the prefetch didn't occur.
2. I have added code in CachedResourceLoader.cpp to not remove prefetches from the cache. They never make it in, and there was a debug mode assertion failure caused by my unit tests here: the wrong element was being removed from the cache in the case that a prefetched resource was also a subresource.
My apologies for not catching these earlier.
Um... Turns out the fix I made, never landed: https://bugs.webkit.org/show_bug.cgi?id=35404
Gavin's fix may be unnecessary here.
Comment on attachment 74976 [details]
Gavin, can you try with Eric's patch applied? His fix is more general, so if it works for this case, that's probably better.
Eric's more general fix definitely does it. I'll obsolete my patch.
Eric, can you please land yours?
*** This bug has been marked as a duplicate of bug 35404 ***
> Eric's more general fix definitely does it. I'll obsolete my patch.
Should we land the test from your patch after we land Eric's patch?
Yes, we should, but it should *also* be after I land an "onload" handler to <link rel=prefetch>, since that will make all our tests for prefetching less flakey.