TimerEvent observer not working for VR (OpenXR)

Hello, I came across a problem when trying to execute a TImerEvent callback in my VR (OpenXR) c++ app.

The problem is: The TimerEvent callback is never called when working with VR.

When in a non-VR enviroment an observer works fine and a callback is fired. To simplify things I created a test app based on the Timer example.

Below you can see a simple code that should print out a message each XX miliseconds but it doesn’t matter what I try it just don’t.

#include <vtkSmartPointer.h>
#include <vtkCommand.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkOpenXRRenderer.h>
#include <vtkOpenXRRenderWindow.h>
#include <vtkOpenXRRenderWindowInteractor.h>
#include <vtkPolyDataMapper.h>


class TimerCallback : public vtkCommand
{
public:
    static TimerCallback* New()
    {
        cout << "TimerCallback constructor hit" << endl;
        return new TimerCallback;
    }

    void Execute(vtkObject* caller, unsigned long eventId, void* callData) override
    {
        cout << "Pre-IF step" << endl;
        if (vtkCommand::TimerEvent == eventId)
        {
            cout << "Timer event triggered!" << endl;
        }
    }
};

int main() {
    vtkSmartPointer<vtkOpenXRRenderer> renderer = vtkSmartPointer<vtkOpenXRRenderer>::New();

    vtkSmartPointer<vtkOpenXRRenderWindow> renderWindow = vtkSmartPointer<vtkOpenXRRenderWindow>::New();
    renderWindow->AddRenderer(renderer);

    vtkSmartPointer<vtkOpenXRRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkOpenXRRenderWindowInteractor>::New();
    renderWindowInteractor->SetRenderWindow(renderWindow);

    renderWindow->Render();
    renderWindowInteractor->Initialize();

    vtkSmartPointer<TimerCallback> timerCallback = vtkSmartPointer<TimerCallback>::New();

    renderWindowInteractor->AddObserver(vtkCommand::TimerEvent, timerCallback);
    renderWindowInteractor->CreateRepeatingTimer(100);
    
    renderWindowInteractor->Start();

    return EXIT_SUCCESS;
}

I understand that RenderWindow must call Render() method before setting up observers as well as RenderWindowInteractor must be initialized too.

I tried setting up different miliseconds values, I tried moving Render() and Initialize() methods to a different place in my code and non worked.

I also tried a VR controller vtkCommand::Move3DEvent and vtkCommand::Select3DEvent observers and they both worked just fine.

Did I miss something? Is there a way for a VR app to be able to work with a TimerEvent observer?

Since you are working in C++, you can very easily determine what’s happening using the debugger. You can add a breakpoint into your callback’s Execute method and see what is calling it when you are not using VR. Probably the feature is just missing from the corresponding VR class and you can implement it by copy pasting it there (or if it is something longer and so you don’t want to duplicate code then you can move the code to some base class and call it from both the non-VR and VR class).