QuickBlox / quickblox-android-sdk

QuickBlox Android SDK includes code snippets with main use cases and framework JAR library.
BSD 3-Clause "New" or "Revised" License
417 stars 697 forks source link

Attempt to invoke interface method 'boolean com.quickblox.chat.connections.ChatConnectionExtensionAble.isSupportStreamManagement()' on a null object reference #736

Closed digitalmidges closed 1 year ago

digitalmidges commented 3 years ago

When I'm during a Video or an Audio call, and the user who made the call "kill" the app from the task manager. Im getting a weird bug.

In my Service which handle the QB communication I'm override 'onTaskRemoved'

override fun onTaskRemoved(rootIntent: Intent?) { super.onTaskRemoved(rootIntent) if (QuickbloxManager.isLoginToQuickBlox()) { // in order to use quickblox video we must log in to chat first doAfterSuccessQuickbloxLogin() } else { QuickbloxManager.doLoginFlow() } }

private fun doAfterSuccessQuickbloxLogin() {
    if (ChatManager.isLoginToChatService()) {
        killServiceAndHangUpCall()
        try {
        } catch (e: IllegalStateException) {
            killServiceAndHangUpCall()
        }
    } else {
        // we must login to the chat before sending the message
        ChatManager.loginToChat(object : QBEntityCallback<Void> {
            override fun onSuccess(aVoid: Void?, bundle: Bundle?) {
                try {
                    killServiceAndHangUpCall()
                } catch (e: IllegalStateException) {
                    killServiceAndHangUpCall()
                }
            }
            override fun onError(e: QBResponseException) {
                killServiceAndHangUpCall()
                Log.d(TAG, "onError: $e")
            }
        })
    }
}

notice that for some reason I'm not logged in to the chat service.. After trying to login ignorer to hangup the call Im getting this error:

Attempt to invoke interface method 'boolean com.quickblox.chat.connections.ChatConnectionExtensionAble.isSupportStreamManagement()' on a null object reference

What can I do? I must handle the situation that a user can exit the video call from recent task.. Any idea?

If the User that answer the call (Not the one who made the call) do the same thing - its working fine...

This is some of my code:

// Chat init { val configurationBuilder = QBTcpConfigurationBuilder() configurationBuilder.socketTimeout = 300 QBSettings.getInstance().logLevel = LogLevel.DEBUG QBChatService.setDebugEnabled(BuildConfig.DEBUG) QBChatService.setConfigurationBuilder(buildChatConfigs()) QBChatService.setDefaultPacketReplyTimeout(15*1000) qbChatService.setUseStreamManagement(true) }

private fun buildChatConfigs(): QBChatService.ConfigurationBuilder {
    val configurationBuilder = QBChatService.ConfigurationBuilder()
    configurationBuilder.socketTimeout = QuickbloxUtils.SOCKET_TIMEOUT
    configurationBuilder.isUseTls = QuickbloxUtils.USE_TLS
    configurationBuilder.isKeepAlive = QuickbloxUtils.KEEP_ALIVE
    configurationBuilder.isAutojoinEnabled = QuickbloxUtils.AUTO_JOIN
    configurationBuilder.setAutoMarkDelivered(QuickbloxUtils.AUTO_MARK_DELIVERED)
    configurationBuilder.isReconnectionAllowed = QuickbloxUtils.RECONNECTION_ALLOWED
    configurationBuilder.setAllowListenNetwork(QuickbloxUtils.ALLOW_LISTEN_NETWORK)
    configurationBuilder.port = QuickbloxUtils.CHAT_PORT
    return configurationBuilder
}

// Video private fun configureQuickblox() { QBRTCConfig.setDebugEnabled(BuildConfig.DEBUG) QBRTCConfig.setAnswerTimeInterval(60) QBRTCConfig.setDisconnectTime(10) QBRTCConfig.setDialingTimeInterval(5) QBRTCConfig.setMaxOpponentsCount(2) QBRTCConfig.setDebugEnabled(true) QBRTCMediaConfig.setAudioCodec(QBRTCMediaConfig.AudioCodec.ISAC) QBRTCMediaConfig.setVideoCodec(QBRTCMediaConfig.VideoCodec.H264) // AcousticEchoCanceler QBRTCMediaConfig.setUseBuildInAEC(true) // Enable OpenSL ES audio if device supports it QBRTCMediaConfig.setUseOpenSLES(false) QBRTCMediaConfig.setAudioProcessingEnabled(true) // Enable Hardware Acceleration if device supports it QBRTCMediaConfig.setVideoHWAcceleration(true) QBRTCMediaConfig.setVideoWidth(QBRTCMediaConfig.VideoQuality.VGA_VIDEO.width) QBRTCMediaConfig.setVideoHeight(QBRTCMediaConfig.VideoQuality.VGA_VIDEO.height) }

alexparvus1 commented 3 years ago

@digitalmidges the issue is really strange and the logic of your application is unclear for me. Please provide some logs (with this error) to give us an understanding of your application flow, and we will try to help you.

digitalmidges commented 3 years ago

@alexparvus1 when two users are in a video call or an audio call, I'm starting a foreground service to handle the call elapsed time and etc... the service also responsible for the events from Quickblox

I'm getting a weird bug in this scenario: User A is calling User B -> User B answer the call and the two start talking -> after a while User A ( who made the call ) decided to exit the app from recent task (recent task - swipe to exit) -> from the foreground service, onTaskRemoved called

And this is the bug, I can't disconnect from the call in the scenario The call never hang up unless User B hang up...

This is the crash log:

Attempt to invoke interface method 'boolean com.quickblox.chat.connections.ChatConnectionExtensionAble.isSupportStreamManagement()' on a null object reference

Any Idea what I should do?

alexparvus1 commented 3 years ago

You just need to handle calls in another service or make your service responsible for displaying a notification with call details. And if your application has been closed by the user - you should launch them when the user presses on a notification or launch the application by pressing the application icon. Look how I made this flow in the videochat sample: https://github.com/QuickBlox/quickblox-android-sdk/tree/master/sample-videochat-java

ghost commented 2 years ago

@digitalmidges Hello

This is Nikolay from QuickBlox support.

Please let me know if you had a chance to check the previous reply and try the provided solution.