element-hq / element-hq/element-android

Frequently crashes in the background.

Open
#8,894 16 comments 2 reactions 0 assignees View on GitHub
T-Defect
Dominant language
Kotlin
Stars
3.7k
Forks
917
PR merge metrics
No merged PRs in 30d

Description

### How To Reproduce

~~~sh
#!/system/bin/sh
adb shell input KEYCODE_HOME && \
sleep 5400
~~~

[^1]

[^1]: [`stackoverflow.com/revisions/24662044/2`](https://stackoverflow.com/revisions/24662044/2#:~:text=static%20final%20int-,KEYCODE_HOME,-Added%20in%20API)

### Outcome

- #### What Was Expected

No crashes.

- #### What Occurred Instead

```YAML
FATAL EXCEPTION: main
Process: im.vector.app, PID: 594
java.lang.RuntimeException: Unable to start service im.vector.app.fdroid.service.GuardAndroidService@ba7286d with null: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.vector.app/.fdroid.service.GuardAndroidService
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4840)
at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2290)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8223)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:977)
Caused by: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service im.vector.app/.fdroid.service.GuardAndroidService
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
at android.os.Parcel.readParcelableInternal(Parcel.java:4870)
at android.os.Parcel.readParcelable(Parcel.java:4852)
at android.os.Parcel.createExceptionOrNull(Parcel.java:3052)
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.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6761)
at android.app.Service.startForeground(Service.java:775)
at im.vector.app.fdroid.service.GuardAndroidService.onStartCommand(GuardAndroidService.kt:15)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4822)
... 9 more
```

This may relate to [`doublesymmetry/react-native-track-player/issues/2231`](https://github.com/doublesymmetry/react-native-track-player/issues/2231#issuecomment-1876044514).

- #### Frequency Of Occurrence

The undermentioned screenshot demonstrates the frequency of these recurrences:

![`Screenshot_20240903-192055`](https://github.com/user-attachments/assets/c1ae3778-5052-4df9-981f-470c4ea04072)

### Hardware

1.

~~~pwsh
#!/usr/bin/env pwsh
$Object = [Ordered]@{}
@(
'ro.product.brand'
'ro.build.product'
) | ForEach-Object {
$Value = (adb shell "getprop $_").Trim()
If ($Value) {
$Int64 = 0L
$Object[$_] =
If ([Long]::TryParse($Value, [Ref]$Int64)) {
$Int64
} Else {
$Value
}
}
}
$Object |
ConvertTo-Json -Compress |
yq -P
~~~

1.

~~~YAML
ro.product.brand: Fairphone
ro.build.product: FP5
~~~

### OS Version

1.

~~~pwsh
#!/usr/bin/env pwsh
$Object = [Ordered]@{}
@(
'ro.build.display.id'
'ro.build.fingerprint'
'ro.build.version.sdk'
'ro.build.version.sdk_full'
) | ForEach-Object {
$Value = (adb shell "getprop $_").Trim()
If ($Value) {
$Int64 = 0L
$Object[$_] =
If ([Long]::TryParse($Value, [Ref]$Int64)) {
$Int64
} Else {
$Value
}
}
}
$Object |
ConvertTo-Json -Compress |
yq -P
~~~

1.

~~~YAML
ro.build.display.id: FP5.UT27.B.059.20240809
ro.build.version.sdk: 34
~~~

### Application Version And Origin

> ~~~ini
> sourcePackage=im.vector.app
> versionCode=40106182
> ~~~

…from [`f-droid.org/repo/im.vector.app_40106182.apk`](https://f-droid.org/repo/im.vector.app_40106182.apk).

### Homeserver

[`matrix.org`](https://matrix.org/)

### Will you send logs?

Yes

### Are you willing to provide a PR?

No

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.