Skip to content

[BUG] Calling: disposing a 2nd call agent never returns #2244

@JasonWeinzierl

Description

@JasonWeinzierl

Describe the bug

Calling CallAgent.dispose() blocks forever on the second attempt.

I'm able to create a CallClient, create a CallAgent, and dispose both successfully; but after creating a 2nd call client and a 2nd call agent, disposing the 2nd call agent will block indefinitely. Attempting to create another client or agent in the same app process causes a crash.

Workaround: if I just skip disposing the call agent entirely and only dispose the client, everything works fine.

Exception or Stack Trace

No exception, the calling thread blocks indefinitely:

callAgent.dispose()

I see these logs, but I'm not sure if they're related:

Thread[47,tid=15580,Native,Thread*=0xb400007310eef410,peer=0x15383020,"mqt_v_native"] recursive attempt to load library ".../lib/arm64-v8a/libACSCallingShared.so"

To Reproduce
Steps to reproduce the behavior:

  1. Start an Android app using Azure Communication Calling.
  2. Create a CallClient, CommunicationTokenCredential, and CallAgent.
  3. Call dispose() on the call agent, credential, and client.
  4. Repeat steps 2-3. The caller will lock up on callAgent.dispose().

Code Snippet

val callClient = CallClient(callClientOptions)

val tokenRefreshOptions = CommunicationTokenRefreshOptions { ... }

val credential = CommunicationTokenCredential(tokenRefreshOptions)

val callAgent = callClient
    .createCallAgent(context, credential, callAgentOptions)
    .get()

// Later, after the agent is "connected" state:
callAgent.dispose() // Blocks forever the 2nd time.

credential.dispose()
callClient.dispose()

// Repeat.

Expected behavior

dispose() should return every time it is called on a un-disposed call agent.

Disposing multiple call agents should be supported (e.g. user A logs in, logs out, user B logs in, logs out).

Screenshots

N/A

Setup (please complete the following information):

  • OS: Android
  • IDE : Android Studio Panda 4 | 2025.3.4 Patch 1
  • Version of the Library used: com.azure.android:azure-communication-calling:2.16.1-beta.1
    • I also used 2.16.1-beta.3, and experienced the same problem.
    • Due to Google Play Store's 16KB requirement, we are unable to downgrade to our previously known working version 2.6.0-beta.8 without violating 16KB alignment.

Additional context

Things I already confirmed:

  • The 2nd agent is in the "connected" state before we dispose it.
  • Right before disposing, I confirmed the agent is still connected.
  • Moving token credential dispose to before/after the agent dispose does nothing.
  • Running dispose on a separate thread doesn't fix it (val executor = Executors.newSingleThreadExecutor()); it just hangs on that thread instead.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Assignees

No one assigned

    Labels

    customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions