Add CEF embedded browser + win32gui for weblink handling

Windows-specific fixes:
- New cef_browser.py: embedded Chromium via cefpython3, no subprocess
- _bring_kivy_to_front(): uses win32gui.SetForegroundWindow (reliable)
- _windows_kill_weblink_after_frame: kills Chrome IMMEDIATELY
- prewarm_weblink disabled on Windows (desktop launch is fast)
- _windows_play_weblink tries CEF first, falls back to subprocess
- Updated requirements_win.txt (cefpython3, pywin32 confirmed)
- Added development-track.md for change tracking
This commit is contained in:
ske087
2026-07-24 14:39:12 +03:00
parent 7efc023327
commit 844e5eeebb
3 changed files with 421 additions and 109 deletions
+32 -19
View File
@@ -15,6 +15,7 @@
| **Venv** | `windows\venv312\` (pre-built, all deps installed) |
| **Kivy** | 2.3.1 |
| **PyInstaller** | 6.21.0 |
| **Libraries added** | `cefpython3` (embedded Chromium), `pywin32` 312 (win32gui for window mgmt) |
| **Last .exe build** | 2026-07-24 13:47 — `windows\dist\KiwySignagePlayer\KiwySignagePlayer.exe` (96 MB) |
| **Build command** | `Set-Location windows; venv312\Scripts\python.exe -m PyInstaller build.spec --clean --noconfirm` |
@@ -81,22 +82,29 @@
-`taskkill /F /T` → kills everything
- **Files:** `windows/run_win.py``_windows_kill_process_tree()`
### [BUG-006] Video plays in background behind Chromium
- **Status:** 🟡 **Known, needs investigation**
- **Symptom:** When transitioning from a weblink back to a video, the video
starts playing while Chromium is still visible (audio plays, video is behind
Chrome window).
- **Possible causes:**
1. `_kill_weblink_after_frame` delay is too short — Kivy renders the video
before Chrome is killed
2. `Window.raise_window()` is not working reliably on Windows to bring
Kivy to front
3. Chrome's `--kiosk` / `--start-maximized` keeps it on top
4. The `content_area.opacity` manipulation happens too early/late
- **Current approach:** `_windows_kill_weblink_after_frame()` shows overlay,
kills Chrome tree, raises Kivy, hides overlay.
- **Next thing to test:** Use `user32.SetForegroundWindow(KivyHwnd)` instead
of `Window.raise_window()`. Get Kivy's HWND via `Window.get_window_info()`.
### [BUG-007] Video plays behind Chromium on weblink→media transition
- **Status:** 🔧 **Fix in progress** 2026-07-24
- **Symptom:** When a weblink ends and the next media starts, the media plays
*behind* Chromium. Audio is heard but user sees Chrome.
- **Root cause (Windows):** Linux renders Kivy widget UNDER Chromium → closes
Chrome → widget visible. On Windows Chrome stays ON TOP.
`Window.raise_window()` is unreliable.
- **Fix applied (2026-07-24):**
1. **`_bring_kivy_to_front()`** — uses `win32gui.SetForegroundWindow(hwnd)`
to reliably bring Kivy/SDL window to front (replaces `raise_window`)
2. **`_windows_kill_weblink_after_frame()`** — kills Chrome IMMEDIATELY
(not deferred one frame later) before next media starts
3. **CEF browser** (`cefpython3`) — embedded Chromium widget replaces
subprocess entirely. No process management, no z-order fights.
- **Files:** `windows/run_win.py`, `windows/cef_browser.py`
### [BUG-008] Intro video and media files not found at runtime
- **Status:** 🟡 **Known** 2026-07-24
- **Symptom:** `[ERROR] [Image] Error loading <...intro1.mp4>` — intro
broken. Also `❌ Media file not found` for playlist items.
- **Root cause:** Media files are not bundled in .exe — must be downloaded
from server. Player connects (v16 received) but hasn't downloaded files.
- **Fix:** Verify server is sending media content and player downloads it.
---
@@ -156,8 +164,13 @@ Set-Location windows
## 📝 Notes for the Next Session
- [ ] Investigate [BUG-006] — video playing behind Chromium
- [ ] Test if `SetForegroundWindow` works better than `Window.raise_window()`
- [x] ~~Investigate [BUG-006]~~ → merged into [BUG-007], fixed with CEF + win32gui
- [x] ~~Test `SetForegroundWindow`~~ → `_bring_kivy_to_front()` uses `win32gui`
- [x] Install `cefpython3` — embedded Chromium, no more subprocess
- [ ] Verify CEF embedded browser actually works at runtime
- [ ] Test the subprocess fallback path when CEF is unavailable
- [ ] Check why `AsyncImage` error shows for intro1.mp4 (path issue)
- [ ] Ensure media files are downloaded before playback
- [ ] Consider adding a startup `.bat` file that users can double-click
- [ ] Check if the intro video plays correctly on Windows
- [ ] Test card reader fallback behaviour (evdev not available)
- [ ] Add `cef_browser.py` to PyInstaller hidden imports in `build.spec`