Investigate OpenRGB startup device rescan reliability #51
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
JackFrostbyte/rgb-aura#51
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
After an OS update, RGB Aura failed to start from the systemd user service because OpenRGB did not detect the GPU at boot.
Manual recovery worked:
This suggests RGB Aura is working correctly, but OpenRGB sometimes starts with an incomplete device list.
Goal
Investigate whether RGB Aura or the systemd user service can improve startup reliability when OpenRGB initially exposes an incomplete device list.
Scope
Research and test possible approaches:
Out of scope
Acceptance criteria
ruff formatpasses where applicable.ruff checkpasses where applicable.Branch workflow
Base branch:
developSuggested work branch:
fix/issue-51-openrgb-startup-device-rescanPull request target:
developDo not merge directly into
main.mainshould only receive tested release-ready changes fromdevelop.Investigation notes — OpenRGB startup device rescan reliability
Current issue being investigated:
fix/issue-51-openrgb-startup-device-rescanSafety conclusion
RGB Aura behaved correctly from a device-mapping safety perspective.
When OpenRGB only reported the motherboard, RGB Aura refused to continue because the GPU was missing.
Observed failure:
This behavior must not be weakened.
RGB Aura should not:
A separate cleanup bug was also observed:
That bug is already covered by issue #45, so it should not be fixed inside issue #51.
Systemd / startup evidence
OpenRGB currently starts from the generated XDG autostart user service:
That generated service comes from:
Current OpenRGB autostart command:
The generated OpenRGB service has:
RGB Aura currently has:
This means RGB Aura is ordered after OpenRGB starts, but it does not guarantee that OpenRGB has finished hardware discovery or that the GPU was available when OpenRGB scanned devices.
OpenRGB / I2C findings
During failed startup, OpenRGB logged this warning:
This matches the observed missing GPU.
When working, OpenRGB reports the GPU as:
Current system evidence shows the required NVIDIA I2C adapter exists after boot:
Other NVIDIA I2C adapters are also present:
Working theory:
OpenRGB may start and scan devices before the GPU I2C path is fully ready. Once OpenRGB has scanned too early, RGB Aura can retry forever and still see the incomplete OpenRGB device list until OpenRGB is manually rescanned or restarted.
OpenRGB CLI / SDK rescan investigation
OpenRGB CLI help was checked.
It exposes options such as:
No documented
--rescanor--scan-devicesCLI option was found.Packet captures were taken on loopback port
127.0.0.1:6742while clicking OpenRGB GUI rescan-related buttons.A clean capture with RGB Aura stopped showed this packet:
Decoded:
After this packet, the GUI requested controller count and controller data. The controller count went from 0 to 2, then OpenRGB returned full device data for:
Upstream OpenRGB source confirms packet type 140 is:
The server handles it through:
However, the Python SDK currently used by RGB Aura is:
Its exposed packet types do not include request rescan devices.
Current exposed packet types include:
Conclusion:
The rescan command exists in OpenRGB upstream, but is not currently exposed by
openrgb-python 0.3.6.Decision for now:
Do not hardcode raw packet 140 directly inside RGB Aura runtime. It is real, but it is not exposed by the SDK dependency and should be treated as a future/experimental path unless implemented cleanly or added upstream to
openrgb-python.Chosen next avenue
The best immediate workaround is to own the OpenRGB SDK server startup sequence instead of relying on the GUI/XDG autostart service.
Planned approach:
Disable OpenRGB GUI autostart.
Add a repo-owned user service:
systemd/user/openrgb-sdk.serviceAdd a startup wait helper:
scripts/wait_for_openrgb_i2c.pyThe helper should wait for the required NVIDIA I2C adapter to appear under
/sys/class/i2c-dev/i2c-*/name, matching something likeNVIDIA i2c adapter.The new OpenRGB SDK service should start OpenRGB only after that adapter is visible:
Update
rgb-aura.serviceto depend on the repo-owned OpenRGB SDK service instead of the generated XDG autostart unit:Update
docs/systemd-user-service.mdto document:openrgb-python 0.3.6.Next session starting point
Continue from branch:
Expected branch:
Next practical local step:
Then add:
scripts/wait_for_openrgb_i2c.pysystemd/user/openrgb-sdk.serviceAnd update:
systemd/user/rgb-aura.servicedocs/systemd-user-service.mdKeep issue #45 separate for the
previous_sigterm_handlercleanup bug.Upstream
openrgb-pythonrescan support — research findingsParallel research into the upstream
openrgb-pythonangle you flagged as a future path. Posting in case it helps shape the long-term plan for this issue. Does not replace the I2C-wait + systemd-controlled SDK service approach you've outlined — that's still the right primary fix for boot-time readiness. This is about complementary runtime tooling.Headline finding: PR already exists
PR #85 "Add rescan function" by ThanhCN0 — opened 2025-10-20, still open, status
mergeable=clean. Verified directly against GitHub today. Does exactly what RGB Aura would need:PacketType.REQUEST_RESCAN_DEVICES = 140toopenrgb/utils.pyrequestRescanDevices()helper toopenrgb/network.pyOpenRGBClient.rescan()toopenrgb/orgb.py(with docstring warning about state-breaking behavior)8657459Two important caveats from the PR thread
protocol_version=5.openrgb-pythoncurrently defaults to protocol 4. Maintainer's reasoning: other v5 features aren't implemented yet, and forcing protocol 5 can produceValueError: 655360 is not a valid ZoneTypeerrors in some setups. So even after PR #85 merges, the calling code has to opt into protocol 5 explicitly (OpenRGBClient(protocol_version=5)) and accept the v5-incomplete caveats. Not free.Project health (verified 2026-05-12)
0.3.6(2025-10-16). What RGB Aura pins to. No newer release.No viable alternative SDK
Surveyed PyPI and GitHub for other Python OpenRGB clients:
OpenRGB-PyClient(bahorn) — MIT, but effectively abandoned since 2023. Author's own README points users toopenrgb-python. Also missing packet 140.openrgb-pythonhas ~40,000 monthly downloads vs ~30 for the alternative.Switching SDKs is not a shortcut.
Server-side semantics
Packet 140 is fire-and-forget. Server handler is a one-liner:
ResourceManager::get()->RescanDevices(). No reply is sent.Completion notification is indirect: if the rescan changes the device list (devices added or removed), the server broadcasts packet 100 (
DEVICE_LIST_UPDATED) to all connected clients.openrgb-pythonalready handles that broadcast atorgb.py:410-411by auto-runningrequestDeviceNum().Critical edge case for this issue: if a rescan happens but the device list doesn't actually change (e.g., GPU still missing because I2C still isn't ready), no broadcast is sent. So a client wanting to confirm "rescan completed and devices recheckable" has to either wait for the broadcast or poll
REQUEST_CONTROLLER_COUNTafter a brief delay. Fire-and-forget means there's no blocking primitive.Implications for #51
The systemd +
wait_for_openrgb_i2c.pyapproach you've outlined remains the correct primary fix. The underlying problem is OpenRGB scanning before I2C readiness, and rescan-after-startup is a band-aid for that, not a substitute.If/when PR #85 lands in
openrgb-pythonAND the user is on OpenRGB server 1.0+ AND the calling code opts into protocol 5, RGB Aura gains a runtime tool: on mapping-validation failure due to a missing expected device, try a rescan + retry once before giving up. Smaller incremental defense than the systemd reordering, complements it.Suggested action (low-effort, high-leverage)
Option A: ping PR #85 noting interest in the feature. Project-neutral wording would be appropriate — no need to name RGB Aura specifically. That nudges the maintainer to revisit.
Option B: if ThanhCN0 stays silent for a few more weeks, open a follow-up PR cherry-picking their two commits with
Co-authored-by: ThanhCN0 <...>attribution. Cheap, faster than clean-room re-implementation, and respects the original author's work. Maintainer is on record with the merge bar already.License note (pre-existing)
openrgb-pythonis GPL-3.0. RGB Aura is MIT (perLICENSE). This is the existing dependency posture, unchanged by upstreaming rescan support — flagging only because it shows up any time we discuss upstream changes.Sources
NetworkServer.cpp ~620, ~1020-1022;ResourceManager.cpp ~369, ~410-424;NetworkClient.cpp 651-659in CalcProgrammer1/OpenRGB on GitLabopenrgb-pythonpatch shape:openrgb/utils.py:102-124(PacketType enum),openrgb/network.py:187-188,213-228(send pattern),openrgb/orgb.py:389-426,461-469(callback + update)Perfect, I updated my issue chat with the new info. I'll continue that this weekend.