https://bugs.kde.org/show_bug.cgi?id=491839

            Bug ID: 491839
           Summary: KDE Connect freezes system UI if a faulty media player
                    is playing on PC.
    Classification: Applications
           Product: kdeconnect
           Version: 24.02.0
          Platform: Android
                OS: Android 14.x
            Status: REPORTED
          Severity: crash
          Priority: NOR
         Component: android-application
          Assignee: albertv...@gmail.com
          Reporter: kde-bugzilla.fg...@aleeas.com
                CC: andrew.g.r.hol...@gmail.com
  Target Milestone: ---

SUMMARY
This might be a strange bug, and I'm surprised myself.

TL;DR: Whenever you play music via the Monstercat Web Player
(https://player.monstercat.app - requires subscription 😶) on the client, KDE
Connect on Android crashes the system UI due to constant
onSessionPlaybackStateChanged events. These eventually trigger a lot of
ConstraintSet's in the system UI which causes it to freeze.

I've only tested it on Windows, but I'll report back if the problem occurs with
the Linux client too.

Anyway, I recently bought a Monstercat Gold subscription and have been
listening to music via their web player for a while now. Today I noticed that
my phone was getting very unresponsive. The symptoms: unlocking was sometimes
impossible, only the on-screen fingerprint reader button was visible and the
background remained black, or when unlocked the extended notification bar could
only be displayed rarely and then with lags. Basically, the phone became
unusable.

After some investigations I found these lines in my ADB logcat:
> D MediaSessionService: onSessionPlaybackStateChanged: 
> record=org.kde.kdeconnect_tp/org.kde.kdeconnect_tp.media_session/12 
> (userId=0)playbackState=PlaybackState {state=PLAYING(3), position=3218, 
> buffered position=0, speed=1.0, updated=3626335, actions=306, custom 
> actions=[], active item id=-1, error=null}allowRunningInForeground=true
> D MediaSessionService: onSessionPlaybackStateChanged: 
> record=org.kde.kdeconnect_tp/org.kde.kdeconnect_tp.media_session/12 
> (userId=0)playbackState=PlaybackState {state=PLAYING(3), position=3233, 
> buffered position=0, speed=1.0, updated=3626351, actions=306, custom 
> actions=[], active item id=-1, error=null}allowRunningInForeground=true
> D MediaSessionService: onSessionPlaybackStateChanged: 
> record=org.kde.kdeconnect_tp/org.kde.kdeconnect_tp.media_session/12 
> (userId=0)playbackState=PlaybackState {state=PLAYING(3), position=3240, 
> buffered position=0, speed=1.0, updated=3626358, actions=306, custom 
> actions=[], active item id=-1, error=null}allowRunningInForeground=true
> D MediaSessionService: onSessionPlaybackStateChanged: 
> record=org.kde.kdeconnect_tp/org.kde.kdeconnect_tp.media_session/12 
> (userId=0)playbackState=PlaybackState {state=PLAYING(3), position=3250, 
> buffered position=0, speed=1.0, updated=3626368, actions=306, custom 
> actions=[], active item id=-1, error=null}allowRunningInForeground=true
> [1000+ messages more like these]
It seems that the web player is manually updating the progress, or something in
the web player is causing KDE Connect to do this. Look at the changing position
attribute in the log. In fact, the playback notification on Android doesn't
have these waves to the left of the cursor that indicate playback. Instead, the
whole line is flat, but the cursor is moving forward (moved by the above
events).

The system UI executes constraint sets in the UI at random intervals, but at
least every few minutes. The logs for that also extend over several hundred
lines. Meanwhile, the system UI is frozen.

> W ConstraintSet: id unknown icon
> W ConstraintSet: id unknown media_seamless
> W ConstraintSet: id unknown media_action_barrier_start
> W ConstraintSet: id unknown media_action_barrier_end
> W ConstraintSet: id unknown media_action_barrier_top
> W ConstraintSet: id unknown remove_text
> W ConstraintSet: id unknown settings
> W ConstraintSet: id unknown dismiss
> W ConstraintSet: id unknown cancel
> W ConstraintSet: id unknown center_vertical_guideline
> W ConstraintSet: id unknown action_button_guideline
> [repeats like this *exactly* for a long time]

These lines may be different for everyone and may not directly cause the
freeze, but they simply show that some background process (probably the system
UI) is doing a lot of work. Those ConstraintSet's cannot be observed in this
amount (and my phone runs stable again) when KDE Connect is disabled, no music
is played or I use some other player like Spotify, YouTube or Jellyfin (also in
Firefox).

I understand that this might be a Monstercat issue and not the responsibility
of KDE Connect, but I think that KDE Connect should apply some rate limits on
playback updates. It seems that this line is hit every millisecond:
https://github.com/KDE/kdeconnect-android/blob/master/src/org/kde/kdeconnect/Plugins/MprisPlugin/MprisMediaSession.kt#L290.
But I didn't test it with a debugger yet. It's just that some faulty web player
on my PC should not be able to freeze my phone 😅

Thanks in advance and sorry for this weird edge-case. I'm happy to provide more
information if required.

- Nicolas

---

STEPS TO REPRODUCE
1. Have your PC paired with your phone and make sure your PC shares your
current music playback with your phone.
2. Go to https://player.monstercat.app, login and play some music. (I know,
this is hard to test)
3. Watch your phone's UI struggle in your ADB logs.

SOFTWARE/OS VERSIONS
Windows Client: 24.02.0 (latest from Microsoft Store version)
Browser which I use for their web client: Firefox 129.0.1

Android app version: 1.32.0 (F-Droid)
Android OS: Google Pixel 6 / GrapheneOS / Android 14
(google/oriole/oriole:14/AP2A.240805.005.F1/2024080600:user/release-keys)

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to