Currently, after each compositing cycle KWin will call the frameRendered method for all damaged windows' Wayland surfaces. This triggers any frame callbacks registered for the surface.
However, based on the specification https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_surface-request-frame frame events are intended to indicate that the compositor is ready to accept a new frame, not that it has just rendered a frame. Hence, it should service frame callbacks for any visible windows, not just those damaged since the last compositing cycle.
This is needed for the upcoming EGLStream-based DRM backend as NVIDIA's Wayland EGL implementation creates frame callbacks and sends damage events in a slightly different sequence than Mesa's which results in vsync'd applications occasionally hanging with KWin's current behavior.