We call viewport.get_texture() to pull the viewport texture.

if I turn off the GPU then everything works perfectly and we get a well defined ordering.

With the GPU we can get an undefined result and can be off by one cycle. This I think must be due to how the GPU delivers the texture and some locking steps that occur.

I only see the problem for web export so far in my testing.

Is there a safe place in the Godot cycle to access the Gpu texture so it will be a well defined result? I've seen some old posts using yield but didn't have any luck yet solving the issue yet.

What do you mean "turn the GPU off"? Can you explain what you are trying to accomplish?

    cybereality We web export our application. So I test on my Mac with Chrome browser. Chrome has an option to disable the GPU which is convenient as a test.

    So everything runs very slow without the GPU but there is no problem of determinism - the viewport texture is always well defined.

    But with the GPU I get some random effects.

    We would like to run our application with deterministic results. Actually for a long time we thought the Viewport access was working deterministically. It's just today I see an effect on one machine only (so far).

    specifically we read the viewport, provide our students with the array of pixels. They write python code to control their robots using the pixel data.

    I am hoping there might be some place using a signal event (such as frame_post_draw) where we can say the GPU is definitely idle and waiting for instructions.

    Many thanks for any assistance.

    I believe the call is this to wait:

    yield(get_tree(), "idle_frame")

      cybereality Thanks. I've tried idle_frame on the yield and also via signal connect. Also tried VisualServer. frame_post_draw and VisualServer.frame_pre_draw but no luck.

      This only happens for web export so I am wondering if perhaps that mode of rendering doesn't have a lock relative to the GPU which is active when I run non-web. As far as I can detect so far it always has perfect determinism for non-web.

      I will do some more investigating on the data I collect from the Viewport to see if I can get more clues about the issue.

      The web is very different. What's rendered in Godot is not shown directly on the screen, it goes through another layer in the browser and then goes to the video drivers, then to the screen.

      For example. on Windows, when you render in Godot it is in OpenGL, but a browser like Chrome actually run ANGLE, which converts calls to DirectX (or Vulkan) and then sends them to the GPU drivers.