Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application get crash in Android -14 #401

Open
rahul-kumawat-vts opened this issue Sep 18, 2024 · 13 comments
Open

Application get crash in Android -14 #401

rahul-kumawat-vts opened this issue Sep 18, 2024 · 13 comments

Comments

@rahul-kumawat-vts
Copy link

rahul-kumawat-vts commented Sep 18, 2024

In our application we have targeted the SDK 34 and we are using screen sharing SDK.

implementation "io.agora.rtc:full-sdk:4.3.1"
implementation "io.agora.rtc:full-screen-sharing:4.3.1"

We have already using a foreground service in app manifest as per the doc
https://docs.agora.io/en/video-calling/core-functionality/screen-sharing?platform=web

Do we need to do anything at our end to fix this crash.

Stack trace: 
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1001, result=-1, data=Intent { (has extras) }} to activity {[com.travelme.app/io.agora.rtc2.extensions.MediaProjectionMgr$LocalScreenCaptureAssistantActivity](http://com.travelme.app/io.agora.rtc2.extensions.MediaProjectionMgr$LocalScreenCaptureAssistantActivity)}: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
at android.app.ActivityThread.deliverResults(ActivityThread.java:5844)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:5888)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:70)
at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:99)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2620)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:222)
at android.os.Looper.loop(Looper.java:314)
at android.app.ActivityThread.main(ActivityThread.java:8732)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:565)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1090)
Caused by: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
at android.os.Parcel.createException(Parcel.java:3041)
at android.os.Parcel.readException(Parcel.java:3024)
at android.os.Parcel.readException(Parcel.java:2966)
at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:313)
at android.media.projection.MediaProjection.<init>(MediaProjection.java:84)
at android.media.projection.MediaProjection.<init>(MediaProjection.java:75)
at android.media.projection.MediaProjectionManager.getMediaProjection(MediaProjectionManager.java:236)
at io.agora.rtc2.extensions.MediaProjectionMgr.onRequestResult(MediaProjectionMgr.java:172)
at io.agora.rtc2.extensions.MediaProjectionMgr$LocalScreenCaptureAssistantActivity.onActivityResult(MediaProjectionMgr.java:257)
at android.app.Activity.dispatchActivityResult(Activity.java:9278)
at android.app.ActivityThread.deliverResults(ActivityThread.java:5837)
... 13 more
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:1048)
at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:192)
at android.os.Binder.execTransactInternal(Binder.java:1346)
at android.os.Binder.execTransact(Binder.java:1282)
@weileifrank
Copy link
Collaborator

The bug has been fixed. You can upgrade the version to 4.4.1 and then try again.

@rahul-kumawat-vts
Copy link
Author

rahul-kumawat-vts commented Sep 20, 2024

Thanks, it's working with version 4.4.1.

One more thing why onUserJoined callback executed again once any user left the channel in version 4.4.1. It was properly working fine with version 4.3.1

override fun onUserJoined(uid: Int, elapsed: Int) {
            super.onUserJoined(uid, elapsed)
            Log.d(TAG, "onUser-Joined: $uid")
            try {
                runOnUiThread {
                    viewModel.visitDetailsLiveData.value?.data?.data?.let { visitDetailsData ->
                        val hostUserId = visitDetailsData.host_user_id
                        val residenceUserId = visitDetailsData.residence_user_id
                        val isHostUser = uid.toString() == hostUserId
                        val isResidenceUser = uid.toString() == residenceUserId

                        if (isMultiVisit) {
                            handleMultiVisitUserJoined(uid, visitDetailsData, isHostUser)
                        } else {
                            handleSingleVisitUserJoined(uid, visitDetailsData, isHostUser, isResidenceUser)
                        }
                    }
                }
            } catch (e: Exception) {
                e.printStackTrace()
            }
        }


override fun onUserOffline(uid: Int, reason: Int) {
            Log.d(TAG, "onUser-Offline: $uid")
            CoroutineScope(Dispatchers.Main).launch {
                try {
                    if (isMultiVisit) {
                        handleMultiVisitUserOffline(uid)
                    } else if (mapHost["host1"] == uid) {
                        handleSingleVisitHostOffline(uid)
                    }
                } catch (e: Exception) {
                    e.printStackTrace()
                }
            }
        }

Screenshot 2024-09-20 at 11 42 59 PM

@rahul-kumawat-bigstep
Copy link

rahul-kumawat-bigstep commented Sep 30, 2024

Can anyone please help update on above issue with latest Agora SDK version 4.4.1

#401 (comment)

@weileifrank

@weileifrank
Copy link
Collaborator

I have tested it. there is no problem for onUserJoined callback with agora version 4.4.1, can you share your demo with me?

By the way, you can also run our demo first to see if the callback is normal

@weileifrank
Copy link
Collaborator

@rahul-kumawat-bigstep

@rahul-kumawat-bigstep
Copy link

rahul-kumawat-bigstep commented Sep 30, 2024

@weileifrank Just checked in your demo as well when any user left the channel (Suppose UID - 452061665) onUserOffline callback executed. In next second for UID-452061665 onUserJoined callback executed.

Please check the logs of your demo App.

Screenshot 2024-09-30 at 6 21 23 PM

@rahul6924
Copy link

@weileifrank Can you please check on priority as our client is facing issue #401 (comment).

@weileifrank
Copy link
Collaborator

i have tested our JoinChannelVideoByToken demo case with agora version 4.4.1 and the logs is as below:

截屏2024-10-03 14 02 52

anyway,can you share your demo with me for checking?

@weileifrank
Copy link
Collaborator

@rahul6924

@rahul-kumawat-vts
Copy link
Author

Hi @weileifrank I have checked with your webdemo and app but still having same issue. Please check the video

https://drive.google.com/file/d/10tRGVG0b7JL5-TgGIr2S9mn-hxC9akhM/view?usp=sharing

@weileifrank
Copy link
Collaborator

@rahul6924
it's a pity,we did not reproduce it.
you can test the case with two android device and then export the sdk log for us ,the sdk path is sdcard/Android/data/io.agora.api.example/files/

sdk_log_path

@rahul-kumawat-vts
Copy link
Author

@weileifrank I will check in two different phone but over use case is mobile and web video streaming. Can you please check the similar case at your end
#401 (comment)

@rahul-kumawat-bigstep
Copy link

rahul-kumawat-bigstep commented Oct 7, 2024

@weileifrank I have tried with two mobile but the behaviour is still same also i didn't get any logs in storage. There is no application folder with package name inside storage directory

Do i need to add the below code in sample application.

val logConfig = LogConfig()
logConfig.level = Constants.LogLevel.getValue(Constants.LogLevel.LOG_LEVEL_INFO)
val ts: String = SimpleDateFormat("yyyyMMdd").format(Date())
logConfig.filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).absolutePath + "/agora/agora_"+ts+".log"

val config = RtcEngineConfig()
config.mLogConfig = logConfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants