element-hq / element-android

A Matrix collaboration client for Android.
https://element.io/
Apache License 2.0
3.31k stars 702 forks source link

element android 1.6.20 crash when joining video group/ jitsi conference. #8885

Open Eternumkr opened 3 weeks ago

Eternumkr commented 3 weeks ago

Description

join a video room, loads for a bit, then crashes. using a google pixel 7 pro running graphineOS. crash log shows the following.

type: crash osVersion: google/cheetah/cheetah:14/AP2A.240805.005/2024080600:user/release-keys package: im.vector.app:40106202 process: im.vector.app processUptime: 24029 + 369 ms installer: com.android.vending

java.lang.RuntimeException: Unable to create service org.jitsi.meet.sdk.JitsiMeetOngoingConferenceService: java.lang.SecurityException: Starting FGS with type mediaProjection callerApp=ProcessRecord{f51e57e 3678:im.vector.app/u0a193} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION] any of the permissions allOf=false [android.permission.CAPTURE_VIDEO_OUTPUT, android:project_media] at android.app.ActivityThread.handleCreateService(ActivityThread.java:4942) at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2414) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at android.app.ActivityThread.main(ActivityThread.java:8623) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ExecInit.main(ExecInit.java:50) at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method) at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:369) Caused by: java.lang.SecurityException: Starting FGS with type mediaProjection callerApp=ProcessRecord{f51e57e 3678:im.vector.app/u0a193} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION] any of the permissions allOf=false [android.permission.CAPTURE_VIDEO_OUTPUT, android:project_media] at android.os.Parcel.createExceptionOrNull(Parcel.java:3192) at android.os.Parcel.createException(Parcel.java:3176) at android.os.Parcel.readException(Parcel.java:3152) at android.os.Parcel.readException(Parcel.java:3094) at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6975) at android.app.Service.startForeground(Service.java:778) at org.jitsi.meet.sdk.JitsiMeetOngoingConferenceService.onCreate(SourceFile:37) at android.app.ActivityThread.handleCreateService(ActivityThread.java:4929) ... 11 more Caused by: android.os.RemoteException: Remote stack trace: at com.android.server.am.ActiveServices.validateForegroundServiceType(ActiveServices.java:2842) at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2530) at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1806) at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:13879) at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3491)

tienipia commented 2 weeks ago

Same issue here, Samsung Galaxy S23, Folder 3.

It happens regardless on android phone model.

Destinyg133 commented 2 weeks ago

On my GF's phone also crashes and she uses samsung I use xiaomi and it does not crash for me

christianrowlands commented 2 weeks ago

I am running into the same issue. Here are my device details:

Worthy of note, this problem does not happen when joining a direct call, it needs to be a conference call.

As best I can tell, it seems to be an Android 14 permissions problem. Now that the Element Android app targets SDK 34 (Android 14) it has to abide by certain permission policies.

The problem seems to be coming from the Jitsi Meet SDK (which explains the conference call). I noticed that version 8.1.1 of the org.jitsi.react:jitsi-meet-sdk is being used, which is over a year old so I tried to upgrade it to 10.1.0 and ran into a different problem.

The new problem is the screen goes black when joining a conference call. Since it appears Element builds its own version of the jitsi SDK (see this build script), that might be why I am running into this problem, or it could be an issue with the latest version of jitsi-meet-sdk.

The errors I see (which may or may not be related) when the screen goes black are:

2024-08-27 08:55:34.089  1937-3099  JitsiMeetLogger         im.vector.app.debug                  E  [features/app] Error(Error){"message":"Exception in HostObject::get(propName:RNGoogleSignin): <unknown>","stack":"index.android.bundle:3378:163\nh@index.android.bundle:2:1789\nindex.android.bundle:3377:225\nh@index.android.bundle:2:1789\nindex.android.bundle:3164:234\nh@index.android.bundle:2:1789\nindex.android.bundle:2977:681\nh@index.android.bundle:2:1789\nindex.android.bundle:2976:172\nh@index.android.bundle:2:1789\nd@index.android.bundle:2:1180\nindex.android.bundle:774:1920\ngeneratorResume@[native code]\nn@index.android.bundle:391:70\nv@index.android.bundle:391:282\nindex.android.bundle:391:341\nf@index.android.bundle:112:208\nv@index.android.bundle:112:1593\nc@index.android.bundle:112:487\nindex.android.bundle:391:232\nindex.android.bundle:774:2367\nindex.android.bundle:3532:1596\ngeneratorResume@[native code]\nn@index.android.bundle:391:70\nv@index.android.bundle:391:282\nu@index.android.bundle:112:158\nindex.android.bundle:112:870\nindex.android.bundle:118:1668\nk@index.android.bundle:118:499\nw@index.android.bundle:118:889\ncallReactNativeMicrotasks@index.android.bundle:118:3059\nvalue@index.android.bundle:57:2897\nindex.android.bundle:57:984\nvalue@index.android.bundle:57:2529\nvalue@index.android.bundle:57:942\nvalue@[native code]\nvalue@[native code]"}
2024-08-27 08:55:34.089  1937-3099  JitsiMeetSDK            im.vector.app.debug                  E  [features/app] Error(Error){"message":"Exception in HostObject::get(propName:RNGoogleSignin): <unknown>","stack":"index.android.bundle:3378:163\nh@index.android.bundle:2:1789\nindex.android.bundle:3377:225\nh@index.android.bundle:2:1789\nindex.android.bundle:3164:234\nh@index.android.bundle:2:1789\nindex.android.bundle:2977:681\nh@index.android.bundle:2:1789\nindex.android.bundle:2976:172\nh@index.android.bundle:2:1789\nd@index.android.bundle:2:1180\nindex.android.bundle:774:1920\ngeneratorResume@[native code]\nn@index.android.bundle:391:70\nv@index.android.bundle:391:282\nindex.android.bundle:391:341\nf@index.android.bundle:112:208\nv@index.android.bundle:112:1593\nc@index.android.bundle:112:487\nindex.android.bundle:391:232\nindex.android.bundle:774:2367\nindex.android.bundle:3532:1596\ngeneratorResume@[native code]\nn@index.android.bundle:391:70\nv@index.android.bundle:391:282\nu@index.android.bundle:112:158\nindex.android.bundle:112:870\nindex.android.bundle:118:1668\nk@index.android.bundle:118:499\nw@index.android.bundle:118:889\ncallReactNativeMicrotasks@index.android.bundle:118:3059\nvalue@index.android.bundle:57:2897\nindex.android.bundle:57:984\nvalue@index.android.bundle:57:2529\nvalue@index.android.bundle:57:942\nvalue@[native code]\nvalue@[native code]"}
2024-08-27 08:55:34.094  1937-3099  JitsiMeetLogger         im.vector.app.debug                  E  [features/base/app] Error(TypeError){"message":"undefined is not an object (evaluating 'r(d[22])._getRouteToRender')","stack":"index.android.bundle:774:1927\ngeneratorResume@[native code]\nn@index.android.bundle:391:70\nv@index.android.bundle:391:282\nindex.android.bundle:391:341\nf@index.android.bundle:112:208\nv@index.android.bundle:112:1593\nc@index.android.bundle:112:487\nindex.android.bundle:391:232\nindex.android.bundle:774:2367\nindex.android.bundle:3532:1596\ngeneratorResume@[native code]\nn@index.android.bundle:391:70\nv@index.android.bundle:391:282\nu@index.android.bundle:112:158\nindex.android.bundle:112:870\nindex.android.bundle:118:1668\nk@index.android.bundle:118:499\nw@index.android.bundle:118:889\ncallReactNativeMicrotasks@index.android.bundle:118:3059\nvalue@index.android.bundle:57:2897\nindex.android.bundle:57:984\nvalue@index.android.bundle:57:2529\nvalue@index.android.bundle:57:942\nvalue@[native code]\nvalue@[native code]"}
2024-08-27 08:55:34.094  1937-3099  JitsiMeetSDK            im.vector.app.debug                  E  [features/base/app] Error(TypeError){"message":"undefined is not an object (evaluating 'r(d[22])._getRouteToRender')","stack":"index.android.bundle:774:1927\ngeneratorResume@[native code]\nn@index.android.bundle:391:70\nv@index.android.bundle:391:282\nindex.android.bundle:391:341\nf@index.android.bundle:112:208\nv@index.android.bundle:112:1593\nc@index.android.bundle:112:487\nindex.android.bundle:391:232\nindex.android.bundle:774:2367\nindex.android.bundle:3532:1596\ngeneratorResume@[native code]\nn@index.android.bundle:391:70\nv@index.android.bundle:391:282\nu@index.android.bundle:112:158\nindex.android.bundle:112:870\nindex.android.bundle:118:1668\nk@index.android.bundle:118:499\nw@index.android.bundle:118:889\ncallReactNativeMicrotasks@index.android.bundle:118:3059\nvalue@index.android.bundle:57:2897\nindex.android.bundle:57:984\nvalue@index.android.bundle:57:2529\nvalue@index.android.bundle:57:942\nvalue@[native code]\nvalue@[native code]"}

Either way, it would be great if someone smarter with the react-native, jitsi, and Element source code could take a look. I am hoping it is an easy fix (several threads mentioned changng npm library versions and clearing the cache).

christianrowlands commented 2 weeks ago

Ok, I can confirm that upgrading to version 10.1.0 of the Jitsi Mobile SDK fixes the issue! I compiled the Jitsi Mobile SDK myself (using the instructions in this repo) for 10.1.0 and got past the issue I was seeing before with the blank screen. No idea why that fixed it, but I am guessing it has something to do with a packaged react-android node library... or something like that.

Anyway, I will gen up a PR tomorrow and see if I can clean up my code enough to get it accepted.

schildbach commented 2 days ago

Since this is a regression from the previous version of Element-Android, and since it affects a major feature likely used by many, can a rollback of the specific change that causes this crash be considered? That way, Element could be used for video/voice conferences again while a more thorough fix is being prepared.

It seems the fix via #8891 and https://github.com/element-hq/jitsi_libre_maven/pull/1 will take much longer to deploy, given the problems with missing dependencies described there.

christianrowlands commented 2 days ago

It seems the change can't be rolled back due to the following: When targeting Android 14 (SDK 34), foreground service permissions must be declared. Starting August 31st, 2024, new app versions are required to target SDK 34 to be published on Google Play (see this link).

Regarding the two PRs you mentioned, I just need someone from the Element team to provide feedback. There are several possible ways to address the decision not to use mavenCentral, but I’d prefer to align with the team’s best practices rather than implementing a solution independently. It's a bit disheartening to have spent time fixing this issue and submitting two PRs without any acknowledgment from the Element team. Even if they don't like the approach I took, just tell me that instead of leaving the PRs hanging.

christianrowlands commented 1 day ago

@bmarty , I have the code written up to fix this bug. Any chance you can take a look at my PRs?