aws / amazon-chime-sdk-android

An Android client library for integrating multi-party communications powered by the Amazon Chime service.
https://aws.amazon.com/chime/chime-sdk/
Apache License 2.0
103 stars 53 forks source link

Running DefaultScreenCaptureSource(v0.17.10) on Android 14 and reporting an error #582

Open qinghua-pactera opened 9 months ago

qinghua-pactera commented 9 months ago

java.lang.IllegalStateException: Must register a callback before starting capture, to manage resources in response to MediaProjection states. at android.media.projection.MediaProjection.createVirtualDisplay(MediaProjection.java:206) at com.amazonaws.services.chime.sdk.meetings.audiovideo.video.capture.DefaultScreenCaptureSource.startInternal(DefaultScreenCaptureSource.kt:192) at com.amazonaws.services.chime.sdk.meetings.audiovideo.video.capture.DefaultScreenCaptureSource.access$startInternal(DefaultScreenCaptureSource.kt:49) at com.amazonaws.services.chime.sdk.meetings.audiovideo.video.capture.DefaultScreenCaptureSource$start$1.run(DefaultScreenCaptureSource.kt:113) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.os.HandlerThread.run(HandlerThread.java:67)

linsang21 commented 8 months ago

Sorry for the delay, is this log from running the demo app with the SDK? Did you observe the same error on previous OS versions?

qinghua-pactera commented 8 months ago

It appears within our APP. For Android 13 or below, this error does not occur and the function is normal. On Android 14, this error occurred.

Compiler Environment: compileSdk 34 targetSdk 34

Phone:Pixel 5,OS 14

qinghua-pactera commented 7 months ago

Sorry for the delay, is this log from running the demo app with the SDK? Did you observe the same error on previous OS versions?

This problem also occurs in the demo app. It should be an adaptation problem to Android 14. Thanks

linsang21 commented 6 months ago

@qinghua-pactera I would think so as well, will post updates once any.

JasonChiAT commented 5 months ago

when using targetSdk 34, it's required to register a callback before mediaProjection.createVirtualDisplay.

add mediaProjection?.registerCallback(object : MediaProjection.Callback() {}, handler) before mediaProjection?.createVirtualDisplay in DefaultScreenCaptureSource.startInternal() to fix.

https://developer.android.com/about/versions/14/behavior-changes-14#callback

gargVader commented 5 months ago

@JasonChiAT Thanks for pointing out. Android team is crazy.

pabloarista commented 3 months ago

Is this going to be addressed this year? We have no issues downloading the source and just fixing it for now, but would prefer if there was an update from the aws team. Right now our Android 14 users are unable to do screen sharing because of this change that we completely missed when updating to the latest sdk.

linsang21 commented 3 weeks ago

Yes, we're working on that. Refer to https://github.com/aws/amazon-chime-sdk-android/commit/2eac126f3822d5ce6a1e3fa21f92054578a1fc58 for the fix, will update once it's been released.

pabloarista commented 3 weeks ago

oh thanks for the update. we did make a temp fix using the above suggestions. just forgot to update here. again thanks