Przeglądaj źródła

Revert " Optimize SpoolBuddy kiosk performance on Raspberry Pi"

This reverts commit 24cda842af0c4748701949cf6b5142f4928cb0a8.
maziggy 2 miesięcy temu
rodzic
commit
7a0ea8faed

+ 1 - 1
CHANGELOG.md

@@ -12,7 +12,7 @@ All notable changes to Bambuddy will be documented in this file.
 - **External Folder Mounting for File Manager** ([#124](https://github.com/maziggy/bambuddy/issues/124)) — Host directories (NAS shares, USB drives, network storage) can now be mounted into the File Manager without copying files. Click "Link External" to point at a Docker bind-mounted path. Files are indexed into the database on scan but accessed directly from their original location — nothing is copied. Supports read-only mode (default, blocks uploads/moves/deletes), hidden file filtering, and automatic thumbnail extraction for 3MF, STL, gcode, and image files. External folders show a distinct icon and info bar with a rescan button. Deleting an external folder only removes the database index, never the actual files. Requested by @S1N4X.
 
 ### Improved
-- **SpoolBuddy Kiosk Performance Optimizations** — Reduced CPU load on Raspberry Pi. Browser: replaced Chromium with cog (WPE WebKit), a purpose-built embedded kiosk browser with a fraction of Chromium's CPU and memory footprint. WebSocket: SpoolBuddy Dashboard and Layout pages now use React Query `select` to extract only `connected` status from printer queries, so temperature/fan/progress updates no longer trigger re-renders on every MQTT tick. Services: expanded install script stripping to disable pipewire audio stack, CUPS printing, rpcbind, upower, polkit, accounts-daemon, xdg-desktop-portal, and mpris-proxy. User-level services are masked via `systemctl --user`.
+- **SpoolBuddy Kiosk Performance Optimizations** — Reduced CPU load on Raspberry Pi. Chromium: overrides Debian's default flags via `/etc/chromium.d/spoolbuddy-kiosk` to disable GPU rasterization (falls back to CPU on Pi's VideoCore VI), enable low-end device mode (caps memory on ≤2GB Pis), and disable smooth scrolling and background networking. The system default `--enable-gpu-rasterization` was conflicting with per-launch flags — the new config replaces all system defaults. WebSocket: SpoolBuddy Dashboard and Layout pages now use React Query `select` to extract only `connected` status from printer queries, so temperature/fan/progress updates no longer trigger re-renders on every MQTT tick. Services: expanded install script stripping to disable pipewire audio stack, CUPS printing, rpcbind, upower, polkit, accounts-daemon, xdg-desktop-portal, and mpris-proxy. User-level services are masked via `systemctl --user`.
 - **SpoolBuddy AMS Slot Action Picker** — Clicking an AMS slot on the SpoolBuddy AMS page now shows a picker with contextual actions: Configure AMS Slot (set filament preset, K-profile, color), and either Assign Spool / Link to Spoolman (when no spool is mapped) or Unassign / Unlink (when one is). Works with both internal inventory and Spoolman. Previously the slot click went straight to the configure modal with no way to manage spool assignments.
 - **Unassign Button in Edit Spool Modal** — The edit spool modal now has an "Unassign" button next to "Delete Tag" that removes the spool's AMS slot assignment, clearing the location column in the inventory table.
 - **SpoolBuddy Settings Device Tab No Longer Scrolls** — Removed the branding card, folded Device ID into the Device Info card, placed Backend/Auth config and diagnostic buttons side by side in a 2-column layout, removed the redundant online/offline status row from Device Info, and tightened spacing throughout. The Device tab now fits on the small SpoolBuddy touchscreen without scrolling.

+ 2 - 3
backend/app/services/spoolbuddy_ssh.py

@@ -226,11 +226,10 @@ async def perform_ssh_update(device_id: str, ip_address: str, install_path: str
             return
 
         # Step 6: Clear browser cache and restart kiosk
-        # Remove WPE WebKit and Chromium cache/SW storage to prevent stale frontend
-        # (covers both cog/WPE and legacy Chromium installs)
+        # Remove Chromium's Service Worker + cache storage to prevent stale frontend
         await _run_ssh_command(
             ip_address,
-            "sudo find /home -maxdepth 5 \\( -path '*/chromium/Default/Service Worker' -o -path '*/.local/share/webkitgtk' -o -path '*/.local/share/cog' \\) -type d -exec rm -rf {} + 2>/dev/null; true",
+            "sudo find /home -maxdepth 5 -path '*/chromium/Default/Service Worker' -type d -exec rm -rf {} + 2>/dev/null; true",
             private_key,
         )
         rc, _, stderr = await _run_ssh_command(

+ 27 - 11
spoolbuddy/install/install.sh

@@ -917,7 +917,7 @@ strip_packages() {
 }
 
 # ─────────────────────────────────────────────────────────────────────────────
-# Kiosk Setup (labwc + cog/WPE WebKit + Plymouth splash)
+# Kiosk Setup (labwc + Chromium + Plymouth splash)
 # ─────────────────────────────────────────────────────────────────────────────
 
 setup_kiosk() {
@@ -949,7 +949,7 @@ setup_kiosk() {
         dpkg-divert --local --rename --add /usr/sbin/update-initramfs >/dev/null 2>&1 || true
         ln -sf /bin/true /usr/sbin/update-initramfs
     fi
-    run_with_progress "Installing kiosk packages" apt-get install -y labwc cog plymouth wlr-randr
+    run_with_progress "Installing kiosk packages" apt-get install -y labwc chromium plymouth wlr-randr
     # Restore real update-initramfs
     if dpkg-divert --list /usr/sbin/update-initramfs 2>/dev/null | grep -q local; then
         rm -f /usr/sbin/update-initramfs
@@ -1097,12 +1097,12 @@ EOF
     <default />
   </mouse>
 
-  <!-- Remove window decorations, maximize browser, prevent unfullscreen -->
+  <!-- Remove window decorations, maximize Chromium, prevent unfullscreen -->
   <windowRules>
     <windowRule identifier="*">
       <serverDecoration>no</serverDecoration>
     </windowRule>
-    <windowRule identifier="cog">
+    <windowRule identifier="chromium">
       <skipTaskbar>yes</skipTaskbar>
       <fixedPosition>yes</fixedPosition>
     </windowRule>
@@ -1111,12 +1111,23 @@ EOF
 </labwc_config>
 EOF
 
-        # Clean up legacy Chromium kiosk config if present
-        rm -f /etc/chromium.d/spoolbuddy-kiosk 2>/dev/null || true
+        # ── Override Debian/RPi Chromium defaults for kiosk performance ──────
+        cat > /etc/chromium.d/spoolbuddy-kiosk << 'CHROMIUM_EOF'
+# SpoolBuddy kiosk: override system defaults for low-end Pi hardware.
+# Replaces CHROMIUM_FLAGS entirely — system defaults (gpu-rasterization,
+# remote-extensions, pings, media-router) are not needed in kiosk mode.
+CHROMIUM_FLAGS="--disable-gpu-rasterization"
+CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disable-smooth-scrolling"
+CHROMIUM_FLAGS="$CHROMIUM_FLAGS --enable-low-end-device-mode"
+CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disable-background-networking"
+CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disable-dev-shm-usage"
+CHROMIUM_FLAGS="$CHROMIUM_FLAGS --disable-pings"
+CHROMIUM_FLAGS="$CHROMIUM_FLAGS --no-default-browser-check"
+CHROMIUM_FLAGS="$CHROMIUM_FLAGS --show-component-extension-options"
+CHROMIUM_EOF
+        success "Chromium kiosk performance flags installed"
 
         # ── kiosk launcher (dynamic URL from spoolbuddy/.env) ─────────────────
-        # Uses cog (WPE WebKit) — purpose-built for embedded kiosk displays.
-        # Much lower CPU/memory footprint than Chromium on Pi hardware.
         local kiosk_launcher="/usr/local/bin/spoolbuddy-kiosk-launch"
         cat > "$kiosk_launcher" << EOF
 #!/usr/bin/env bash
@@ -1148,7 +1159,12 @@ else
     kiosk_url="\$FALLBACK_URL"
 fi
 
-exec cog --platform=wl "\$kiosk_url"
+exec chromium --kiosk --no-first-run --disable-infobars \
+    --disable-session-crashed-bubble --disable-features=TranslateUI \
+    --noerrdialogs --disable-component-update \
+    --overscroll-history-navigation=0 \
+    --ozone-platform=wayland \
+    "\$kiosk_url"
 EOF
 
         chmod 755 "$kiosk_launcher"
@@ -1164,7 +1180,7 @@ EOF
 # Force 1024x600 (panel doesn't advertise this natively)
 wlr-randr --output HDMI-A-1 --custom-mode 1024x600@60 &
 
-# Launch cog (WPE WebKit) via helper that resolves URL from spoolbuddy/.env
+# Launch Chromium via helper that resolves URL from spoolbuddy/.env
 $kiosk_launcher &
 EOF
 
@@ -1453,7 +1469,7 @@ main() {
     download_spoolbuddy
     echo ""
 
-    # ── Step 3b: Kiosk setup (labwc + cog/WPE WebKit + Plymouth) ──
+    # ── Step 3b: Kiosk setup (labwc + Chromium + squeekboard + Plymouth) ──
     setup_kiosk
     echo ""