RegisterAfterAnimationFrameListener
The RegisterAfterAnimationFrameListener method, part of the VSyncObserver class, registers a persistent listener that is called after every VSync signal occurs. Unlike RequestAnimationFrame, which is a one-shot request, no API is exposed to unregister this listener, making it suitable for continuous monitoring or tasks that need to run on every frame.
This method must be called on the BTS (Background Thread Script) thread. It also supports both C++ std::function and C-style function pointer callbacks.
Method Signature
With std::function callback
With C-function callback
Parameters
Callback Functions
The C++ lynx::pub::VSyncObserverCallback signature is:
The C vsync_observer_callback signature is:
Important Notes
- Execution Thread: This method and its callbacks are intended to be used on the BTS thread.
- Persistent Listener: The registered callback will be invoked for every subsequent VSync signal, not just once.
- Lifecycle: Keep the
VSyncObserverinstance alive while the runtime may invoke the callback. The API does not provide an explicit unregister operation.
Example
This example shows how to register a listener to log information for every frame.
Compatibility
LCD tables only load in the browser