fix(ledmatrix-music): skip websocket UTF-8 validation on the YTM socket (1.5.3) - #602
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Verified on hdpi (Pi 4, 512x64) with 1.5.3 deployed and music playing: from 12:24 to 12:31 the YTM socket delivered 11-17 events a minute, and scroll stalls were 0.89% of frames (11,697 frames over the minutes that scrolled), against 6-8.5% with 1.5.2 under the same conditions and ~0.6% with no music. Only about 3 minutes of scrolling fell in that window, but the gap is well clear of noise. |
…et (1.5.5) websocket-client validates every text frame's UTF-8 in pure Python unless wsaccel is installed, and holds the GIL while it does. The YTM Companion pushes its whole player state (~59KB, mostly the queue) every few seconds while music plays. On hdpi (512x64, Pi 4) a py-spy --gil profile put ~16% of the display process's GIL time in websocket/_utils.py _validate_utf8/_decode, and scroll stalls rose from ~0.6% of frames to ~8.5% from the moment the socket connected; with this change they were 0.89% with music playing. Pass skip_utf8_validation through socketio.Client's websocket_extra_options (engineio >= 4.8, already implied by the python-socketio>=5.11 floor). The payload is still decoded and parsed as JSON, which rejects anything malformed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BkfgXMqqwn2w4NN7LRzhxy
d122ff4 to
690721b
Compare
Summary
Scrolling stutters on the whole panel while YouTube Music is playing. The YTM Companion pushes its full player state (~59 KB, almost all of it the play queue) every few seconds, and websocket-client validates each text frame's UTF-8 in pure Python unless
wsaccelis installed, holding the GIL for ~30 ms per push on a Pi 4. This passesskip_utf8_validationthroughsocketio.Client(websocket_extra_options=...). The payload is still decoded and parsed as JSON, which rejects anything malformed.Type of change
Plugin(s) affected
ledmatrix-music (1.5.2 → 1.5.3)
Test plan
main@ 5aa7a631py-spy record --gilwith music playing: ~16% of the display process's GIL time inwebsocket/_utils.py_validate_utf8/_decode, on the Socket.IO read threadvalidate_utf829.8 ms,json.loads1.0 mstest_ytm_skip_utf8_validation.pypins the option on the client;test_ytm_reconnect_backoff.pystill passespython-socketio>=5.11already requirespython-engineio>=4.8.0, whoseClientacceptswebsocket_extra_options(checked in the 4.8.0 wheel)Notes for reviewer
wsaccelwould also fix it, but only where someone installs it; this fixes it for every install.🤖 Generated with Claude Code