Closed Bug 1206538 Opened 9 years ago Closed 9 years ago

Attempting to load image from SW cache fails after SW is active fails on first load.

Categories

(Core :: DOM: Service Workers, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: marcos, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:42.0) Gecko/20100101 Firefox/42.0
Build ID: 20150919004025

Steps to reproduce:

1. I wait for the SW to install and become active. 
2. Then I send an ArrayBuffer to the SW over postMessage(). 
3. That ArrayBuffer is then converted to a blob and stored in a cache. 
4. Then I send a message back to the page saying "ok, I stored the image"
5. I create an Image element and set the source.

If I refresh, then it works fine; as the image is already in the SW cache. 


Actual results:

The image fails to load and instead triggers the `onerror` handler. 


Expected results:

I would expect that after install and activation, I should be able to store blobs in the SW without needing to reload the page. And that I should be able to load those images from dynamically created img elements.
Marcos, does the onerror handler provide any information?  Do you have example code I can use to duplicate this?

In regards to avoiding the reload, please use self.skipWaiting() in your install event handler and self.clients.claim() in your activate event handler.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(marcos)
(In reply to Ben Kelly [:bkelly] from comment #1)
> Marcos, does the onerror handler provide any information? 

No, as it never fires. 

> Do you have
> example code I can use to duplicate this?

Please see:
https://github.com/mozilla/remote-newtab/blob/gh-pages/test/sw_spec.js#L35

Using this SW:
https://github.com/mozilla/remote-newtab/blob/gh-pages/sw.js

To run the actual test needs a bit of setup (npm install + our custom build of gecko which we are working on to do this "remote about:newtab" thing).

I'm happy to help get all that set up if you want to run the actual test.  

> In regards to avoiding the reload, please use self.skipWaiting() in your
> install event handler and self.clients.claim() in your activate event
> handler.

Awesome, thank you! Will try this out!
Flags: needinfo?(marcos)
(In reply to Marcos Caceres [:marcosc] from comment #2)
> (In reply to Ben Kelly [:bkelly] from comment #1)
> > Marcos, does the onerror handler provide any information? 
> 
> No, as it never fires. 

This seems opposite to what you wrote in comment 0 under "actual results".

> To run the actual test needs a bit of setup (npm install + our custom build
> of gecko which we are working on to do this "remote about:newtab" thing).

Can you attach a patch I can apply against central to get that?
(In reply to Ben Kelly [:bkelly] from comment #3)
> (In reply to Marcos Caceres [:marcosc] from comment #2)
> > (In reply to Ben Kelly [:bkelly] from comment #1)
> > > Marcos, does the onerror handler provide any information? 
> > 
> > No, as it never fires. 
> 
> This seems opposite to what you wrote in comment 0 under "actual results".

Oops... got confused with the other image caching bug (where onload always fires). Let me check what actually happens.
 
> > To run the actual test needs a bit of setup (npm install + our custom build
> > of gecko which we are working on to do this "remote about:newtab" thing).
> 
> Can you attach a patch I can apply against central to get that?

Yes, I can try to slap something together.
This was caused by passing a rejected promise to respondWith().
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.