App crashes when leaving Zoom session using UI Toolkit in Jetpack Compose (NullPointerException in UiToolkitView.cleanup)

Hi Team,

I’m using the Zoom UI Toolkit (implementation 'us.zoom.uitoolkit:uitoolkit:2.1.10-1') to implement call functionality in my Android app, which is built using Kotlin and Jetpack Compose.

The issue I’m facing is that when the user clicks the “Leave Call” icon to exit a Zoom session, the UiToolkitView is removed immediately as expected, but the app crashes 1–2 seconds later.

Here’s the crash log:

Process: org.brainhealth.bhp_android.dev, PID: 10736
 java.lang.NullPointerException: Attempt to invoke interface method 'int us.zoom.sdk.ZoomVideoSDKShareHelper.stopShare()' on a null object reference
 at us.zoom.uitoolkit.UiToolkitView.cleanup(UiToolkitView.kt:136)
 at us.zoom.uitoolkit.UiToolkitView.access$cleanup(UiToolkitView.kt:30)
 at us.zoom.uitoolkit.UiToolkitView$videoSdkListener$1.onSessionLeave(UiToolkitView.kt:70)
 at us.zoom.internal.ZoomVideoSDKDelegateHelper$1$4.run(ZoomVideoSDKDelegateHelper.java:3)
 at android.os.Handler.handleCallback(Handler.java:991)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loopOnce(Looper.java:232)
 at android.os.Looper.loop(Looper.java:317)
 at android.app.ActivityThread.main(ActivityThread.java:8934)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:591)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)

Note: This NullPointerException occurs after the onViewStopped() method of the UiToolkitView.Listener is triggered.

Could you please advise on what might be causing this crash and how to properly clean up or prevent it?

Thanks in advance!

Hi @DineshSarma It looks like the code is attempting to call an Share SDK related object after the meeting session has already been disconnected. Can you detail if any screen sharing features were being used when the user ended the meeting?

Thank you @ticorrian.heard
I am not handling anything manually, just using UiToolKitView, following is my how my implementation looks like:

// declaration
val sessionContext = SessionContext(sessionName, jwtToken, userName, password)
val uiToolkitView = UiToolkitView(context)

// to join the session
uiToolkitView.joinSession(sessionContext)
//adding click listener
uiToolkitView.addListener(object : UiToolkitView.Listener {})

// setting UiToolKitView into AndroidView
Box(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight()
) {
AndroidView(
modifier = Modifier
.size(height = screenHeight.dp, width = screenWidth.dp)
.align(Alignment.Center),
factory = { uiToolkitView }
)
}