Skip to content

Fixed video not playing after import - #625

Open
sofian wants to merge 3 commits into
devfrom
bugfix-video-not-playing
Open

Fixed video not playing after import#625
sofian wants to merge 3 commits into
devfrom
bugfix-video-not-playing

Conversation

@sofian

@sofian sofian commented Jul 26, 2026

Copy link
Copy Markdown
Member

Summary

Importing a video froze the UI for ~1s and then often left the source not playing (on Ubuntu 24.04). Root cause: VideoImpl::waitForNextBits() busy-spun on the GUI thread waiting for the first decoded frame. That pattern dates back to the original GStreamer backend, where frames arrived on GStreamer's own thread so spinning was merely wasteful. Since the Qt6 Multimedia port, frames are delivered via QVideoSink::videoFrameChanged on the event loop of the thread that owns the player (the GUI thread) — so the spin blocked the very event loop needed to deliver the frame it was waiting for, guaranteeing a timeout and leaving the media pipeline in a bad state.

  • Video::setUri() now returns immediately with a fallback icon instead of blocking.
  • Video::_pollForBits() replaces the blocking wait with non-blocking QTimer::singleShot-based polling.
  • Source list icon refreshes asynchronously once a real thumbnail is generated (MainWindow::sourcePropertyChanged, mirroring the existing "name" handling).
  • Also fixed an uninitialized _videoType in Video's default constructor (used when loading sources from a project file), which the new fallback-icon logic depends on.

Test plan

  • qmake6 mapmap.pro && make builds clean
  • tests/ suite builds and all 44 existing Qt Test cases pass (QT_QPA_PLATFORM=offscreen ./mapmap_tests)
  • Verified via a standalone harness linking the real Video/VideoPlayerImpl code directly: before the fix, construction always took ~1.4s and always logged "No bits coming"; after the fix, construction returns immediately and bits/dimensions arrive asynchronously without blocking the GUI thread
  • Manually confirmed a real video import plays correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants