Skip to content

Firebase AI Live API on Android leaks/accumulates Firebase Audio threads on rk3588 #7942

@jackleeforce

Description

@jackleeforce

Environment

  • Firebase AI Logic SDK:
    • Reproduced on 17.8.0
    • Reproduced on 17.10.1
  • Backend: GoogleAI / Gemini Developer API
  • Model: gemini-2.5-flash-native-audio-preview-12-2025
  • Android device with issue:
    • Model: rk3588
    • Android version: 12
    • API level: 32
  • Comparison device:
    • Google Pixel 8 Pro
    • Behavior is noticeably more stable there
  • App type:
    • Reproduced in a minimal single-activity Android app with only:
      • Connect
      • Disconnect
      • Simulate goAway
  • Audio mode:
    • LiveSession.startAudioConversation(...)

Problem Summary

On rk3588, Firebase Live audio threads are not reliably released across disconnect/reconnect cycles.

Depending on timing and reconnect path, we observe one or more of these behaviors:

  1. old Firebase Audio / Firebase Blocki threads remain alive after disconnect
  2. reconnect partially reuses old threads but also creates new ones
  3. repeated reconnects, especially after goAway, cause thread count and CPU usage to keep increasing over time
  4. after running for hours, the process becomes unstable and eventually crashes

This is reproducible both:

  • in our production app
  • in a minimal standalone test app

So this does not appear to be caused by app-specific business logic.

Minimal Reproduction

We built a minimal Android app that only does the following:

  • create a LiveSession
  • call startAudioConversation()
  • disconnect using one of:
    • stopAudioConversation() + close()
    • close()
    • stopAudioConversation() + delay + close()
  • reconnect again

We also tested goAway handling in 17.10.1 in two ways:

  1. stop audio and restart on the same session
  2. stop audio -> delay -> close old session -> connect new session -> start audio

Reproduction Steps

Case A: Manual connect / disconnect / reconnect

  1. Launch app
  2. Tap Connect
  3. Wait until audio conversation is active
  4. Tap Disconnect
  5. Tap Connect again, either immediately or after some delay

Case B: goAway / reconnect path

  1. Launch app and connect
  2. Wait for server goAway or simulate the same handling path
  3. Reconnect / restart audio according to app logic
  4. Observe thread list and CPU

Observed Behavior

On rk3588, after disconnect/reconnect cycles we repeatedly observe leftover threads like:

  • Firebase Audio
  • Firebase Blocki

Typical symptoms:

  • after one connection, we see a pair/group of Firebase threads
  • after disconnect, those threads often remain alive
  • after reconnect, sometimes the old threads are reused, but often new Firebase Audio threads are also created
  • repeated reconnects gradually increase thread count and CPU
  • some Firebase Audio threads remain at very high CPU for long periods

Example from a long-running production session on rk3588

  • process thread count grew to about 129
  • process RSS was around 348 MB
  • peak RSS was around 433 MB
  • many historical Firebase Audio threads remained alive simultaneously
  • multiple Firebase Audio threads each consumed significant CPU

Example from the minimal app on rk3588

  • baseline: about 22-24 threads
  • connected: about 38-39 threads
  • after reconnect cycles: thread count rose into the low 40s
  • old Firebase threads remained, and new Firebase threads were added

Example behavior on Pixel 8 Pro

On Pixel 8 Pro, reconnect behavior is noticeably more stable:

  • fewer long-lived leftover Firebase threads
  • reconnect often appears to reuse existing internal threads
  • thread count does not grow as aggressively

Expected Behavior

One of these should happen consistently:

  1. after disconnect, Firebase Live audio threads should be fully cleaned up
  2. or reconnect should safely reuse the same internal audio threads without thread count growth
  3. but it should not keep accumulating Firebase Audio / Firebase Blocki threads over time

What We Tried

We tested all of the following:

  • close() only
  • stopAudioConversation() then close()
  • stopAudioConversation() then wait then close()
  • goAway -> stop audio -> restart audio on same session
  • goAway -> stop audio -> close old session -> connect new session -> start audio

None of them fully solved thread accumulation on rk3588.

Suggested Investigation Areas

This may be related to:

  • device-specific audio stack / HAL behavior on rk3588
  • Firebase Live audio worker lifecycle
  • incomplete cleanup of internal audio/network scopes after disconnect or reconnect
  • interaction between goAway, audio shutdown, and reconnect timing

Request

Could you please investigate whether:

  • LiveSession.close() / stopAudioConversation() are expected to fully terminate all internal Firebase audio threads
  • thread retention on certain Android devices, especially rk3588-based devices, is a known issue
  • there is a recommended reconnect pattern for goAway that avoids accumulating Firebase Audio threads

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions