Bug 182916 - Issues with Service Worker on treebo.com
Summary: Issues with Service Worker on treebo.com
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Service Workers (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-02-18 20:47 PST by Kenji Baheux
Modified: 2018-02-26 09:02 PST (History)
3 users (show)

See Also:


Attachments
Screenshot showing a bad state (1.61 MB, image/png)
2018-02-18 20:47 PST, Kenji Baheux
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kenji Baheux 2018-02-18 20:47:13 PST
Created attachment 334133 [details]
Screenshot showing a bad state

Filing this on behalf of Jeffrey Posnick

Setup:
 Tech Preview 49. 
 https://www.treebo.com
 Uses sw-precache [1] for static assets, but not navigations.

Issues observed:
 - Offline-fallback logic works in Chrome, but never appears to be triggered when navigating offline to https://www.treebo.com. [JS]
 - Once, I was able to get into a state in which the request for the HTML (which isn't served from the cache, but does pass through the SW) was only partially successful. I had to clear out the SW and caches using Safari's Privacy settings to get back into a functional state. [SCREENSHOT]




[1]: https://github.com/GoogleChromeLabs/sw-precache
[JS]: https://static.treebo.com/rodimus/build/client/offline/offline.00000002.js
[SCREENSHOT]: attached
Comment 1 Radar WebKit Bug Importer 2018-02-19 08:14:21 PST
<rdar://problem/37671412>
Comment 2 Chris Dumez 2018-02-19 09:45:13 PST
Someone needs to explain to me how to trigger the offline logic in Chrome. With the latest Chrome Canary, I tried:
1. Load https://www.treebo.com
2. Wait ~10 seconds
3. Reload https://www.treebo.com
4. Wait ~10 seconds
5. Turn off Wifi on my laptop
6. Reload https://www.treebo.com / Or Go to https://www.treebo.com in a new tab
-> I get a generic error about having no internet connection

Behavior is similar on both Chrome and Safari Technology Preview 49.
Comment 3 Kenji Baheux 2018-02-22 22:42:09 PST
Treebo is down for me (403)...
I'll try again over the weekend and see if Jeffrey is back from vacation.
Comment 4 Jeffrey Posnick 2018-02-26 08:25:46 PST
After looking into it some more, it seems like Treebo has a customized service worker that it uses for "mobile" user agents. That service worker script imports https://static.treebo.com/rodimus/build/client/offline/offline.00000002.js which in turn handles the custom offline page for failed navigations.

So, the offline fallback wasn't working in Safari TP 49 when I tested because I was using a "desktop" user agent, and the offline fallback script wasn't imported.

I just upgraded to Safari TP 50 and explicitly switched my user agent emulation to iOS 11.0 - iPhone, and I was served the service worker script with the extra offline fallback logic. It works as expected when I disabled my internet connection and navigated to the page.

I'm not readily able to reproduce the second issue, as it only cropped up once while testing with TP 49. It might have been due to a bug in Safari TP 49 that has since been fixed in Safari TP 50.
Comment 5 Chris Dumez 2018-02-26 09:02:11 PST
Marking as resolved as per last comment.