google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.36k stars 1.84k forks source link

`setFrameCompletedCallback` is only called once, then it crashes #7826

Closed hannojg closed 1 month ago

hannojg commented 2 months ago

Describe the bug

We are trying to render into an AVAssetWriter, for that we need to know when the frame is completed. We are trying to use swapChain->setFrameCompletedCallback for that purpose. The frame callback is called once, but after that we get an assertion error:

Assertion failed: (mInvoker && mInvocable), function operator(), file Invocable.h, line 134.

To Reproduce

  1. Set a frame completed callback using the metal backend:
    auto swapChain = _engine->createSwapChain(nativeWindow, SwapChain::CONFIG_APPLE_CVPIXELBUFFER);
    swapChain->setFrameCompletedCallback(
                                       nullptr, [](SwapChain* UTILS_NONNULL swapChain) {
                                           // note: we pass a completely empty callback, and it still crashes
                                       });

Expected behavior

The callback gets called continuously while rendering.

Screenshots

Screenshot 2024-05-06 at 13 30 13

Logs If applicable, copy full logs from your console here. Please do not use screenshots of logs, copy them as text, use gist or attach an uncompressed file.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

n/a

hannojg commented 2 months ago

cc @mrousavy