From aa631c8e9fe1952eec7cf8b53dfae24b8da2395e Mon Sep 17 00:00:00 2001 From: Prabhaav Pillai Date: Thu, 5 Nov 2026 13:15:42 -0500 Subject: [PATCH] backoff logic and improve widget art handling --- openpilot/starpilot/galaxy/batch_routes.py | 2 +- openpilot/starpilot/galaxy/hotspot_worker.py | 2 +- .../starpilot/galaxy/tests/test_hotspot.py | 2 ++ .../starpilot/galaxy/web/js/layout-preview.js | 5 ++-- .../starpilot/galaxy/web/js/onroad-layout.js | 7 +++-- .../starpilot/galaxy/web/js/widget-art.js | 3 +- openpilot/starpilot/soloist/supervisor.py | 3 +- .../starpilot/soloist/tests/test_connect.py | 19 +++++++++++++ .../system/starport/car_interface.py | 8 +++--- .../system/starport/projection_layout.py | 3 +- .../starport/tests/test_car_interface.py | 8 ++++++ openpilot/starpilot/ui/onroad_map.py | 16 ++++++----- openpilot/starpilot/ui/onroad_navigation.py | 18 ++++++------ .../starpilot/ui/tests/test_onroad_map.py | 13 +++++---- .../ui/tests/test_onroad_navigation.py | 28 ++++++++++++++++++- 15 files changed, 99 insertions(+), 38 deletions(-) diff --git a/openpilot/starpilot/galaxy/batch_routes.py b/openpilot/starpilot/galaxy/batch_routes.py index 922fe89b3a..de33961457 100644 --- a/openpilot/starpilot/galaxy/batch_routes.py +++ b/openpilot/starpilot/galaxy/batch_routes.py @@ -54,7 +54,7 @@ def delete_records(self, path, payload, sentry_events_lock, crash_reports_lock, def widget_art_header(image): - """The renderer's widget-art tEXt chunk, base64-encoded for an HTTP header ('' when absent or oversized).""" + """Encode bounded PNG sprite metadata for the preview response header.""" import base64 import struct signature = b'starpilot-widget-art\0' diff --git a/openpilot/starpilot/galaxy/hotspot_worker.py b/openpilot/starpilot/galaxy/hotspot_worker.py index 4c79391efa..d2f1892f40 100644 --- a/openpilot/starpilot/galaxy/hotspot_worker.py +++ b/openpilot/starpilot/galaxy/hotspot_worker.py @@ -258,7 +258,7 @@ class HotspotController: self.failures = 0 def backoff(self): - return min(RETRY_S * 2 ** self.failures, MAX_RETRY_S) + return min(RETRY_S * 2 ** min(self.failures, 5), MAX_RETRY_S) def tick(self, config): if not config['enabled']: diff --git a/openpilot/starpilot/galaxy/tests/test_hotspot.py b/openpilot/starpilot/galaxy/tests/test_hotspot.py index ee2a5b011d..4b1f975528 100644 --- a/openpilot/starpilot/galaxy/tests/test_hotspot.py +++ b/openpilot/starpilot/galaxy/tests/test_hotspot.py @@ -360,6 +360,8 @@ def test_repeated_failures_back_off_and_success_resets(): now[0] += 300 assert controller.tick(CONFIG)['state'] == 'starting' assert controller.tick(CONFIG)['active'] and controller.failures == 0 and controller.backoff() == 15 + controller.failures = 10000 + assert controller.backoff() == hotspot_worker.MAX_RETRY_S def test_ap_that_keeps_exiting_backs_off(): diff --git a/openpilot/starpilot/galaxy/web/js/layout-preview.js b/openpilot/starpilot/galaxy/web/js/layout-preview.js index 65e99b0db4..deb0271762 100644 --- a/openpilot/starpilot/galaxy/web/js/layout-preview.js +++ b/openpilot/starpilot/galaxy/web/js/layout-preview.js @@ -59,7 +59,7 @@ export function sceneHidesWidget(scene, profile, id, layout = {}, widgets = {}) // The device renders one preview at a time and answers a second request with 429. // Feeds sharing a queue take turns instead, widget art before the backdrop. -// Room for a rendered PNG to cross the Galaxy tunnel, not just the local network. +// Allow for Galaxy tunnel latency. const PREVIEW_TIMEOUT_MS = 20000 export class PreviewQueue { @@ -184,8 +184,7 @@ export class LayoutPreviewFeed { this.last = item const request = new AbortController() this.request = request - // The clock starts once this feed holds the renderer: waiting behind the other feed (slow over a tunnel) - // used to eat the whole budget and flip the backdrop to "unavailable" before it was even sent. + // Queue time does not consume the response timeout. let timeout = null let rejectAborted const aborted = new Promise((_, reject) => { rejectAborted = () => reject(new Error("Preview request cancelled")) }) diff --git a/openpilot/starpilot/galaxy/web/js/onroad-layout.js b/openpilot/starpilot/galaxy/web/js/onroad-layout.js index db0beb1438..c8a9a6e5de 100644 --- a/openpilot/starpilot/galaxy/web/js/onroad-layout.js +++ b/openpilot/starpilot/galaxy/web/js/onroad-layout.js @@ -151,6 +151,9 @@ export class OnroadLayoutFeed { export const LayoutWidgetPreview = { props: ["widget", "palette", "profile", "scene", "clock24Hour", "native", "art"], + computed: { + roadNameSize() { return Math.max(18, Math.min(this.widget.width, this.widget.height) * .075) }, + }, methods: { withAlpha, modeLines(scene, profile) { @@ -299,8 +302,8 @@ export const LayoutWidgetPreview = { - - Desert Inn Road + + Desert Inn Road