heihei blog

Blog icon by Unsplash https://unsplash.com/@virussinside

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



本記事は、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


  • 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)


  • 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?


  • Androidでは、Firebase AnalyticsやFirebase CrashlyticsはGoogle Play Services経由でログを送信している
    • そのため、アプリのタスクがキルされている状態でも動作する
  • Firebaseはオフラインファーストのサービスではないが、通常利用によるオフライン状態(地下鉄や混雑時)などには想定されており、2つの方法を用いてオフライン対応をしている
    • Local cache
    • Exponential backoff and retry
  • オフライン時にもオンラインと同等のサービス提供が必須なアプリには適切なツールではないかもしれない