Skip to main content

Notes - Firebase offline: What works, what doesn't, and what you need to know (Firebase Summit 2019)

note

This article has been translated by Gemini.

In this Notes article, I roughly jotted down notes in English from the content of the English session video/podcast. This article is intended to be read as a reference while watching the video. I hope this article helps you even a little when you watch the actual video. (Please feel free to contact me if there are any errors or typos! m(__)m)

This article is based on Firebase offline: What works, what doesn’t, and what you need to know (Firebase Summit 2019).

Should we care about offline anyway?
#

  • Yes! Users may..

    • be in crowded place

    • go underground

  • Firebase is not an offline-first platform, but offline-tolerant

What works
#

  • It (mostly) works

    • Caching things locally

    • Exponential back-off and retry

Firebase Auth
#

  • you only have the access to the user object

  • you can’t login

Gotchas
#

  • Login

  • Auth Persistence

    • Tells how long you stay logged in

    • Trade-off between offline-experience and security

Cloud Firestore
#

How large is that cache, anyway?
#

  • For mobile - 100MB

  • For web - 40MB

  • on-device cache is not indexed right now

    • unpack and scan every document you are searching

    • if your cache is too big or too many writes this can be quite slowly

  • Maybe not pre-loading your cache too much is better than overloading cache data

  • Adjust your cache size by configuring Firestore

Cloud Storage
#

  • you can save large object to the cloud

  • specifying a reference like a path to upload and download the content

All The Measurement Libraries
#

  • On Android, all this uploading is done by Google Play Services

    • That is why if your app were crashed on Android, you can see that crashed data and upload it for you

    • if offline, exponential back-off retry

  • Performance Monitoring

    • 10MB of data, shared across all apps (Android)

    • 10MB of data, per app (iOS)

    • Oldest data usually gets eliminated

  • Analytics

    • About 100,000 events

    • Most recent data gets eliminated

  • Crashlytics

    • 9 crashes(up to 150k each)

Conclusion
#

  • If you’re offline, things mostly just work

  • Designed for occasional offline moments, but not offline-first

    • if you need complete offline experience, maybe not the right tool
  • Measurement tools don’t trust data that too old

    • Mostly 72 hours old?

Impressions / Summary / Key Takeaways
#

  • On Android, Firebase Analytics and Firebase Crashlytics send logs via Google Play Services.
    • Therefore, they work even if the app task is killed.
  • Firebase is not an offline-first service, but it anticipates offline states from regular use (subways or crowded places) and uses two methods for offline support:
    • Local cache
    • Exponential backoff and retry
  • It might not be the right tool for apps where providing the same service offline as online is essential.

That’s all!