Skip to content

Intermittent MMKV Data Loss after Background/Kill (Encrypted) with InvalidProtocolBuffer truncatedMessage Decode Error #903

@pratikSeven

Description

@pratikSeven

Hi Team,

We are seeing an intermittent but impactful issue where the encrypted MMKV instance sometimes comes back empty after the app is backgrounded or force-closed for a period, resulting in user logout and loss of cached session/context. Looking for guidance to diagnose and confirm whether this is a corruption, flushing, or decoding/encryption edge case.

Summary

  • Normal operation: Reads/writes work reliably while the app is active.
  • Problem: After backgrounding or the OS/user killing the app (and reopening minutes later), the MMKV store occasionally initializes empty.
  • Frequency: Sporadic but frequent enough to affect production users.
  • Error observed (Android & iOS logs):
  • MiniPBCoder.cpp:591::decodeOneMap InvalidProtocolBuffer truncatedMessage
  • [E] MiniPBCoder.cpp:591::decodeOneMap InvalidProtocolBuffer truncatedMessage
  • Encryption is enabled.
  • One stored value is a JSON string (~4.9 kB). All other keys are very small (tokens, flags, etc.).

Steps to (Intermittently) Reproduce

  • Launch app; write several small keys plus one ~4.9 kB JSON string.
  • Confirm keys exist via getAllKeys().
  • Background app OR swipe-kill.
  • Wait 10–30+ minutes (sometimes less).
  • Relaunch.
  • Observe: storage is empty; decode error logged natively.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions