Issue: Player crashes after 2-3 minutes during editing
Hypothesis: The background upload thread may be interfering with playback
even with the Clock.schedule_once fix.
Action: Temporarily disable the background upload to see if this is
the root cause of the crashes.
Edits will still be saved locally, just not uploaded to server during
this diagnostic test.
If player is stable without this thread, the issue is in the upload
logic or thread management.
BUG: Background upload thread was crashing the app
Problem:
- _upload_to_server() runs in daemon thread
- Was directly setting self.player.should_refresh_playlist from thread
- Kivy is NOT thread-safe for direct state modifications
- App crashed after 2-3 minutes during editing
Root cause:
Line 503: self.player.should_refresh_playlist = True
This directly modified Kivy object state from non-main thread
Caused race conditions and memory corruption
Solution:
- Use Clock.schedule_once() to schedule flag update on main thread
- Ensures all Kivy state modifications happen on main thread
- Thread-safe and proper Kivy API usage
- No more app crashes during editing
This was causing the app to crash every 10-20 seconds during edits.
Should now be stable!
CRITICAL FIX - This was the main issue preventing edited images from appearing!
Problem:
- Edited media was being uploaded to server successfully
- Server updated the playlist (new version returned: 34)
- BUT player never reloaded the playlist
- So edited images stayed invisible until restart
Solution:
1. EditPopup now sets should_refresh_playlist flag when upload succeeds
2. Main player checks this flag in check_playlist_and_play()
3. When flag is set, player immediately reloads playlist
4. Edited media appears instantly without needing restart
Testing:
- Created diagnostic script test_edited_media_upload.py
- Confirmed server accepts edited media and returns new playlist version
- Verified SSL fix works correctly (verify=False)
Now edited images should appear immediately after save!
Root cause identified from logs:
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate
The server uses a self-signed certificate (like production), but the edited media
upload endpoint was not disabling SSL verification while other API calls do.
Solution:
- Add verify=False to requests.post() call in _upload_to_server()
- Matches the SSL verification handling in get_playlists_v2.py
- Add warning about SSL verification being disabled
- Now edited images can upload successfully to server
This fixes the upload failures that were preventing edited images from being
synced to the server.
Critical fixes for image editing workflow:
1. Keep local edited files as backup (don't delete after server upload)
- Server may not process upload immediately
- Keeps edits safe locally in case server fails
- Prevents loss of edited images
2. Include original filename in metadata sent to server
- Server needs to know which file was edited
- Allows proper tracking and versioning
3. Improved error logging for server upload
- Now logs detailed errors (404, 401, timeout, connection)
- Shows clear messages when server doesn't support endpoint
- Helps diagnose why edits aren't syncing to server
4. Better user feedback during save
- Shows 'Saved to device' status first
- Then 'Upload in progress' to show server sync happening
- Clarifies local vs server save status
Bug symptoms fixed:
- Edited images now persist locally after restart
- Server upload now sends correct file information
- Clear error messages if server upload fails
- User understands 'local save' vs 'server sync' steps
- Commented out forced pygame backend (causes issues with display initialization)
- Added SDL_VIDEODRIVER and SDL_AUDIODRIVER fallback chains (wayland,x11,dummy)
- Limited KIVY_INPUTPROVIDERS to wayland,x11 (avoids problematic input providers)
- Reduced FFMPEG_THREADS from 4 to 2 (conserves Raspberry Pi resources)
- Reduced LIBPLAYER_BUFFER from 2MB to 1MB (saves memory)
- Fixed asyncio event loop deprecation warning (use try/except for get_running_loop)
- Better exception handling for cursor hiding
These changes fix the app crashing after 30 seconds due to graphics provider issues.
- Replaced failing systemd user service with system-wide service
- System service more reliable on Wayland/Bookworm systems
- Service creates /etc/systemd/system/kiwy-player.service
- Runs as pi user with proper display environment variables
- Adds Restart=on-failure for robustness
- Keeps XDG and cron methods as additional fallback layers
This resolves autostart failures after recent system updates.
Added support for both X11 and Wayland environments:
Display Server Detection:
- Auto-detects Wayland via WAYLAND_DISPLAY environment variable
- Falls back to X11 commands if not Wayland
- Works seamlessly on both display servers
Wayland-specific tools:
- wlopm - Wayland output power management (keeps display on)
- wlr-randr - Output management for wlroots compositors
- ydotool - Mouse movement for Wayland (alternative to xdotool)
- systemd-inhibit integration for idle prevention
Enhanced display keep-alive script:
- Detects display server type on startup
- Uses appropriate commands based on environment
- Wayland: wlopm, wlr-randr, ydotool
- X11: xset, xdotool, xrandr
- Both: tvservice for HDMI power control
App-level improvements (main.py):
- Detects Wayland via os.environ check
- Executes Wayland-specific commands when detected
- Maintains X11 compatibility for older systems
Installation improvements:
- Auto-installs Wayland tools if Wayland is detected
- Attempts to install: wlopm, wlr-randr, ydotool
- Graceful fallback if packages unavailable
This ensures HDMI power management works correctly on:
- Raspberry Pi OS with X11 (older versions)
- Raspberry Pi OS with Wayland (Bookworm and newer)
- Any Linux system using either display server
- Added signal_screen_activity() method to SignagePlayer class
- Runs every 20 seconds automatically
- Also triggered on any touch/user input events
Multiple methods used to keep display awake:
- xset s reset - Resets screensaver timer
- xset dpms force on - Forces display on
- xdotool - Subtle mouse movement to trigger activity
This complements the system-level power management:
- Works alongside display power management settings
- Non-blocking and non-critical (fails gracefully)
- Signals every 20 seconds + on user input
- Prevents display from sleeping during playback
Screen should now remain active throughout media playback.
- Created .keep-screen-alive.sh wrapper script with multiple methods:
* systemd-inhibit (primary - prevents OS-level sleep/suspend)
* xset commands (prevents X11 screensaver)
* Mouse movement (prevents idle timeout)
- Added screen-keepalive.service systemd unit:
* Runs xset s reset every 30 seconds
* Auto-restarts on failure
* Integrated with graphical session
- Multiple layers of screen protection:
* HDMI blanking disabled
* CPU power saving disabled
* System sleep/suspend disabled
* X11 screensaver disabled
* DPMS (Display Power Management) disabled
* Display forced on periodically
Screen will now remain active while player is running, preventing lockups or blank screens during playback.
- Enhanced install.sh with comprehensive autostart workflow:
* XDG autostart entry (desktop environment)
* systemd user service (most reliable)
* LXDE autostart support (Raspberry Pi OS)
* Cron fallback (@reboot)
* Terminal mode enabled for debugging
- Added Raspberry Pi power management features:
* Disable HDMI screen blanking
* Prevent CPU power saving (performance mode)
* Disable system sleep/suspend
* X11 screensaver disabled
* Display power management (DPMS) disabled
- Fixed sudo compatibility:
* Properly detects actual user when run with sudo
* Correct file ownership for user configs
* systemctl --user works correctly
- Player launches in terminal for error visibility
- Autostart configured to use start.sh (watchdog with auto-restart)
- Modified ssl_utils.py to treat 404 errors as expected when server doesn't have /api/certificate endpoint
- Changed verify_ssl setting to false in app_config.json to allow HTTPS connections without certificate verification
- This allows the player to connect to servers that don't implement the certificate endpoint
- Created src/edit_popup.py module for EditPopup and DrawingLayer classes
- Moved EditPopup UI definition to signage_player.kv (reduced main.py by 533 lines)
- Moved CardSwipePopup UI definition to signage_player.kv (reduced main.py by 41 lines)
- Improved code organization with better separation of concerns
- main.py reduced from 2,384 to 1,811 lines (24% reduction)
- All functionality preserved, no breaking changes
- Added checkbox in Settings screen to enable/disable edit feature
- Setting stored in app_config.json as 'edit_feature_enabled'
- Edit workflow now validates: player setting, media type, server permission, card auth
- Shows appropriate error message when edit is blocked at any validation step
- Defaults to enabled (true) if not set
- All conditions must be met for edit interface to open
- Implemented CardReader class to read data from USB card readers
- Added CardSwipePopup with 5-second timeout and visual feedback
- Card data is captured and included in edit metadata
- Card data sent to server when edited images are uploaded
- Added evdev dependency for USB input device handling
- Fallback mode when evdev not available (for development)
- Created test utility (test_card_reader.py) for card reader testing
- Added comprehensive documentation (CARD_READER_AUTHENTICATION.md)
- Added access-card.png icon for authentication popup
- Edit interface requires card swipe or times out after 5 seconds
- Migrated to get_playlists_v2 with improved auth system
- Added WebP image format support for playback and editing
- Implemented edit_on_player permission check from server playlist
- Added user authentication layer for edit function (placeholder: player_1)
- Implemented versioned saving with metadata (user, timestamp, version)
- Added server upload functionality for edited media
- Fixed playlist update after intro video completion
- Added hostname and quickconnect_code to player feedback
- Improved error handling for upload failures (non-blocking)
- Added pencil edit button to player controls
- Created EditPopup with drawing layer for image annotation
- Drawing tools: color selection (red/blue/green/black), thickness control
- Features: undo last stroke, clear all strokes, save edited image
- Playback automatically pauses during editing
- Only images (.jpg, .jpeg, .png, .bmp) can be edited
- Edited images saved with '_edited' suffix in same directory
- Drawing layer with touch support for annotations
- Full toolbar with color, thickness, and action controls
- Added custom half-width on-screen keyboard widget (keyboard_widget.py)
- Keyboard appears at bottom center when input fields are active
- Integrated keyboard in exit popup and settings popup
- Fixed install.sh: added --break-system-packages flag for pip3
- Fixed install.sh: added fallback to online installation for version mismatches
- Removed old Kivy 2.1.0 tar.gz that was causing conflicts
- Keyboard includes close button for intuitive dismissal
- All input fields trigger keyboard on touch
- Keyboard automatically cleans up on popup dismiss
Features:
- Automatically activates .venv virtual environment
- Creates venv if it doesn't exist
- Installs dependencies on first run
- Checks for configuration file
- Changes to project directory automatically
- Deactivates venv on exit
Usage:
bash start.sh
Updated README with new recommended startup method.
Features:
- Create repo/ folder structure for offline packages
- python-wheels/ for Python packages (.whl files)
- system-packages/ for APT packages and .deb files
- Add download_offline_packages.sh to populate Python wheels
- Add download_deb_packages.sh to download system .deb packages
- Update install.sh with smart online/offline detection
- Auto-detects repo folder and uses offline packages
- Falls back to online installation if repo is empty
- Supports --offline flag for explicit offline mode
- Update requirements.txt with async dependencies:
- aiohttp==3.9.1 for async HTTP client
- asyncio==3.4.3 for async I/O framework
- Add OFFLINE_INSTALLATION.md with complete guide
- Add .gitignore to exclude downloaded packages from repo
- Document all system dependencies in apt-packages.txt
Downloaded packages:
- 18 Python wheels with all dependencies
- Total size: ~50 MB for Python packages
- Ready for offline deployment
Changes:
- Implement async/await pattern for non-blocking server communications
- Use asyncio event loop integrated with Kivy for smooth UI
- Run playlist updates and feedback sending in thread pool
- Prevent UI freezing during network I/O operations
- Add video error handling and playback state management
- Implement delayed video playback start (wait 0.5s for loading)
- Add video error callback for better error recovery
- Cancel all async tasks on application shutdown
- Process async tasks every 100ms without blocking Kivy event loop
New file:
- convert_video_for_rpi.sh: FFmpeg script for optimizing videos (1080p @ 30fps, H.264)