Skip to content

Enable interfaces to (early) start the playlist

Fatih Uzunoğlu requested to merge fuzun/vlc:start-playlist-in-interface into master
  • Adding interfaces take time. In general, it can be considered an expensive operation.
  • In some cases, the interface becomes ready for playback before fully initialized but can not return open because full initialization takes time.
  • Starting the playlist seems to be depending on the situation of the interface. I assume that's why playlist start is called after the interface added currently (to make sure video embedding works).
  • The interface knows the best itself when to start the playlist (in video embedding situation), therefore it can be delegated to start the playlist.
  • If interface can not start the playlist early, and is waited for full initialization, then startup time becomes compromised. Starting the playlist seems to be the last action in the startup chain, and if it is done earlier, we effectively reduce the starting time of the application.

Currently, Qt interface returns the open call without waiting for full initialization, notably the asynchronous scene graph initialization (cost of Qt Quick/QML). The documentation for QQuickWindow::sceneGraphError() states that [1]:

Applications should connect to this signal if they wish to handle errors, like graphics context creation failures, in a custom way. When no slot is connected to the signal, the behavior will be different: Quick will print the message, or show a message box, and terminate the application.

It is a mistake in my opinion that now Qt may fail after "successfully" added, and that it terminates the whole application. I fixed this in !6013. However, since that fix essentially waits for Qt's full initialization, the playlist start is also delayed.

Only with Direct Composition video integration it is necessary to wait for scene graph initialization. In other video integration methodologies, there is no need to wait and Qt may start the playlist early and ultimately !6013 does not compromise the startup time for non-Direct Composition cases.

As @robUx4 reported, currently Direct Composition video integration causes crash when VLC starts with a video because when playlist is started, Qt has not yet finalized the scene graph initialization. !6013 fixes that issue as well.

I have used a timer to see how much delay it incurs to wait for Qt's scene graph initialization:

  • 300 ms late with RHI OpenGL (measured on native Linux, debug build), this is the default one on Linux
  • 350 ms late with RHI Vulkan (measured on native Linux, debug build)
  • 250 ms late with RHI D3D11 (measured on Windows 10 VM, debug build), this is the default one on Windows
  • 500 ms late with RHI D3D12 (measured on Windows 10 VM, debug build)

In my personal opinion, any number above 50 ms justifies an adjustment in core. This adjustment is not really invasive, so I hope it gets accepted. If there are better ways, please let me know.

[1] https://doc.qt.io/qt-6/qquickwindow.html#sceneGraphError

Edited by Fatih Uzunoğlu

Merge request reports