client-sdk-flutter
client-sdk-flutter copied to clipboard
Android 10 screen sharing crash[bug]
Crash when screen sharing is turned on for the first time. Restart the app as normal
第一次使用屏幕分享功能会闪退,重启app后不在闪退。 Android 10 . Flutter 3.3.3 compileSdkVersion 33 targetSdkVersion 30
java.lang.SecurityException:Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
android.os.Parcel.createException(Parcel.java:2091)
......
Caused by:
android.os.RemoteException:Remote stack trace:
at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(libmapleservices.so:16751240)
at android.media.projection.IMediaProjection$Stub.onTransact(libmapleframework.so:27092540)
at android.os.Binder.execTransactInternal(libmapleframework.so:6256148)
at android.os.Binder.execTransact(libmapleframework.so:6257944)
It should be related to the first setting of FOREGROUND_SERVICE, can this issue be reproduced in client-sdk-flutter/example?
It should be related to the first setting of FOREGROUND_SERVICE, can this issue be reproduced in client-sdk-flutter/example?
yes ,only happens the first time
Only happens the first time after uninstalling and reinstalling
I did some investigation, maybe it's a bug of flutter_background, after the first execution of FlutterBackground.initialize( androidConfig: androidConfig); will throw an exception, when you wait for 1 second and then re-execute FlutterBackground.enableBackgroundExecution(); it will succeed. so I created an experimental fix
https://github.com/livekit/client-sdk-flutter/compare/main...experiment/fix-screen-sharing-crash-on-first-boot
You can wait 1 second after the first exception and try again, and screen sharing will work as expected.
PR: https://github.com/livekit/client-sdk-flutter/pull/203/files