Skip to content

egl: negotiate reference counting

Rémi Denis-Courmont requested to merge Courmisch/vlc:egl into master

According to the specification, EGL displays are not reference-counted by default. As such, eglTerminate() will terminate a display even if there are other users for it in the same process.

This becomes a fatal problem if platform display is shared by multiple components, and the EGL display parameters are identical or deemed compatible by the EGL driver. Typically, this will occur with the window provider and the display.

To fix this, the Khronos group defined an EGL extension to negotiate reference counting explicitly.

  • On Android, this patch makes no differences as the EGL enables reference counting by default, regardless of the baseline specifications.
  • On X11, this patch makes no differences because the module will create its own private Xlib Display as the platform display, such that the EGL display is not shareable.
  • This patch matters on Wayland where the wl_display pointer must be shared between the window provider and display. Without this patch, Either the window provider or the display cannot use EGL.
  • On Windows, the situation ought to be similar to Wayland, though this is much less of an issue, as EGL is not typically used.

This patch does not require reference counting if not available as this would needlessly break on Android and X11, as well as with the non-embedded XDG-shell window provider on Wayland.

Fixes #25531 (closed)

Merge request reports