Repository navigation
Description
Build:
Angular CLI: 1.7.3
Node: 8.1.4
OS: darwin x64
Angular: 5.2.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker
@angular/cdk: 5.2.4
@angular/cli: 1.7.3
@angular/flex-layout: 5.0.0-beta.14
@angular/material: 5.2.4
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.7.2
webpack: 3.11.0
New Safari Experimental service worker is on by default and works fine
as long as you do not upload an image in your PWA then it appears to hang. Getting some sort of Firebase storage issue. If I turn off Safari service worker my app works as expected.
Using latest firebase angularfire2 storage with task to show pre-loader (using angularfire2 based on David East's blog (see below). PWA worked fine before iOS 11.3 update but with service worker on by default will fail if uploading an image. In the prior iOS release there was an bug when using the camera if the PWA was added to home screen the camera was disabled. Apple fixed the camera bug with iOS 11.3.
David East's Blog to upload image using Angular Angularfire2:
https://blog.angular.io/file-uploads-come-to-angularfire-6842352b3b47
Getting Firebase error from Safari Desktop macOS High Sierra version 10.13.4 (Apr 2018 update)
code_: "storage/unknown"
message_: "Firebase Storage: An unknown error occurred, please check the error payload for server response."
name_: "FirebaseError"
serverResponse_: "Client uploaded to the wrong offset (262144 instead of 0)."
NOT SURE IF A NEW ANGULAR POLYFILL IS NEEDED TO ENABLE SERVICE WORKERS.
THANKS!
FOUND ISSUES WITH SAFARI AND SERVICE WORKERS ENABLED HANGS ANGULAR PWA USING ANGULARFIRE2 UPLOAD.
- Chrome (Android) version XX
- Chrome (iOS) version XX
- Firefox version XX
- [ x] Safari (desktop) version XX
- [ x] Safari (iOS) version XX
- IE version XX
- Edge version XX
Activity
markgoho commentedon Apr 8, 2018
@MatteoNY consider opening an issue over at the AngularFire2 repo for this issue you're experiencing.
As far as what it takes to enable service workers, there is very good documentation here: https://angular.io/guide/service-worker-intro
MatteoNY commentedon Apr 13, 2018
Mark: (markgoho) thanks for the suggestion to review the Angular.io docs.
I subscribe to #AskFirebase on YouTube.com a video on PWAs mentioned that service-workers need to ignore Firebase's dynamic data because it has advanced offline features.
https://youtu.be/iHqqUoqvYx4
This was an Ah-ha moment! After reading more about service-workers, I'm not exactly clear on what to put in the ngsw-config.json file to ignore dynamic Firebase. I don't want it to also ignore static assets.
I've been following PWA's since the last ng-conf and I've taken a course on Udemy where the instructor got into writing a service-worker. My preference is to use the one with the Angular CLI.
I can experiment with ngsw-config.json file but I'd rather spend the time exploring Angular Elements.
I have a few suggestions:
A how to guide on Angular.io on how exclude dynamic data from a service (Firebase where it's not needed - as per the video). For example, visit Chrome's network tab and view dynamic/static data and to add a node, for example, under the dataGroups add: ", { name: firebase-dynamic: !**firebase }" in the ngsw-config.json file. I'm making this up, but it would be nice to know.
Add a new feature to Chrome's Lighthouse to use it's magic to inform me that since I'm using Firebase add this to your ngsw-config.json file to ignore dynamic Firebase data (not needed), static data will persist :-). Possibly a URL to a tutorial (suggestion 1) on how to optimize your service-worker when using Firebase.
As I've mentioned in prior post, if I disable the service-worker via the main.ts ( // navigator.serviceWorker.register('/ngsw-worker.js');). My app works as expected on Safari (Mac and iPhone) as well as the other browsers.
This appears to not to be a service-worker bug but a configuration for the service-worker.
I hope the above helps.
Many thanks,
Matt
aSegatto commentedon Jul 12, 2018
We are experiencing a similar issue while uploading a text file. We excluded firebase comunications from the ngsw cache by adding :
in the ngsw-config file, but nothing changed. Error occurs only on safari . We opened an issue #24853
gkalpak commentedon Jul 12, 2018
Just to add some info, (despite what that video says about Angular's SW implementation) I don't think you need any special configuration to not cache specific requests. The SW will only cache what it is explicitly configured to cache.
aSegatto commentedon Jul 13, 2018
Ok, how can we further investigate what's happening ? is there a way to see what's going on in the service worker ?
We believe that posting data to a cloud function without multi part should avoid this issue, but we 'd like to do this as the last option.
gkalpak commentedon Jul 13, 2018
SWs are just javascript code, so you can debug them as usual (add breakpoints etc). That's what I would do if I wanted to investigate an issue like this.
arikanorh commentedon Aug 1, 2018
I'm current hitting the same problem. It doesnt work on Safari on iOS. But cant debug since i cant see the console
9 remaining items
GIOkafor commentedon Jan 29, 2019
Does that go in your main.ts file?
koraysels commentedon Jan 29, 2019
@GIOkafor no it is a separate js file, I do this after the build command. To do so you can an script property in your package.json. Or of you use pm2 to deploy you can run it with pm2 after ‘ng build —prod’
avilao commentedon Feb 18, 2019
But that removes caching completely right? Not just for safari.
Robstaer commentedon Feb 25, 2019
Is there a new update on this matter? I'm having the same problem: PWA on IOS breaks the image upload to firestorage, both in the webbrowser as well as in the app...
maxime1992 commentedon Feb 26, 2019
Had to remove the service worker from prod because of that.
We've got plenty of tests, unit, integration and also E2E with Cypress but as Cypress doesn't support service workers correctly (few issues but basically it'd also cache the tests) we deactivate them while doing E2E testing. So everything was green and we thought we were ok deploying to prod. 🤕
As they're doing agressive caching on the client side it's a bit 😱 too and the service worker module should just work flawlessly because it's really really hard after deploying to prod with a service worker to expect all the clients to behave correctly after...
koraysels commentedon Feb 26, 2019
No it just disables it for firebasestorage requests...
avilao commentedon Mar 4, 2019
Sorry my question wasn't specific. It disables firestoredatabase requests in all browsers, right?
Robstaer commentedon Mar 14, 2019
Why is this issue closed, even though not resolved yet?
@koraysels advice cannot be a long-term solution =/
shigurenimo commentedon Mar 18, 2019
@gkalpak Please open this issue again. You can see bugs at this URL on iOS 12.1.4.
gkalpak commentedon Mar 18, 2019
As mentioned in #23244 (comment), this is a limitation in some browser's
fetchimplementation. There are some work arounds mentioned on this thread and the ability to "properly" work around such limitations is tracked in #21191 (hence this issue is closed).Work around for issue:angular/angular#23244
Merge pull request #3 from yhirochick/pwa
jek-bao-choo commentedon Aug 3, 2019
For those using AngularFire2, this issue is also mentioned
angular/angularfire#1439
angular/angularfire#1909
angular-automatic-lock-bot commentedon Sep 15, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.