When ScreenSaverEnginge is started by launchd with is only used for background mode than the animation becomes lagging. In any other mode, like preview window in system preferences or normal screensaver mode there is no lagging. This happens independent of the used render (same for OpenGL and Metal).
when starting the "background mode" from Terminal window directly with "/System/Library/CoreServices/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -window" there is no lagging at all -> lagging seams related to starting it from launchd as a daemon instead of a normal user program
tried changing process priority handling with "nice" and "renice", but this do not change anything -> it is not an process priority problem
I suspect something with the timing events of the ScreenSaverView that fires "animateOneFrame" method is odd when startet as daemon with launchd. Timing Events seams to collected over a period and then all fired together over a short time. I think I remember Craig Federighi presented this feature called "Timer Coalescing" years ago for 10.9 on a keynote and they use it to save energy. Seams they use it only for daemons (started by launchd I use it for the start of the background mode) and never for normal user programs (like starting it from Terminal as user).
I investigate the "Timer Coalescing" trace a bit further:
disabling "Timer Coalescing" systemwide by use of _"sudo sysctl -w kern.timer.coalescingenabled=0" -> This completely solve the issue and I see no more lags! -> Anyway, but doing this systemwide is not an option, since this will drain battery too much and also needs admin rights. -> But it shows that "Timer Coalescing" is really the problem here!
I tired to disable "Timer Coalescing" only for the Screensaver by using launchd option "LegacyTimers" set to "true" -> unfortunately this makes no difference! According to older descriptions this option should have worked? -> Maybe Apple broke this option years ago?
I investigate the "LegacyTimers" trace a bit further:
looking for official description of launchd configuration with "man launchd.plist" shows, that "LegacyTimers" set to "true" only works when a second option "ProcessType" is set to "Interactive" -> This solve the issue and I see no more lags! And now we only did it for the screensaver and not system wide.
When ScreenSaverEnginge is started by launchd with is only used for background mode than the animation becomes lagging. In any other mode, like preview window in system preferences or normal screensaver mode there is no lagging. This happens independent of the used render (same for OpenGL and Metal).