0

Is ENTER_FRAME always received, even if another process occupies the CPU, OR the listener might miss one or more ENTER_FRAME events -then receive several of those events delayed in a batch as usually happens in Windows?

(I'm using pure AS3 and Stage3D with 3D GPU rendering -no 2D display objects, Flash timeline, movieclips etc).

BEIC
  • 67
  • 7

1 Answers1

0

ENTER_FRAME depends on frame rate. And frame rate is not a constant - it depends on a lot of factors, few of which are CPU and GPU. The listener won't miss anything, it's just that the ENTER_FRAME event will be dispatched irregularly.

Andrey Popov
  • 7,362
  • 4
  • 38
  • 58
  • So you mean that ENTER_FRAME event is being dispatched after GPU has ended processing the previous frame in order for AS3 to start preparing the next frame render? I'd expect that it would be dispatched in sync with the desktop (and monitor) frame rate (which **is** a constant), then the code would take care of situations of longer renderings while everything would always be in sync (why they make simple things difficult -I wonder). – BEIC Apr 10 '14 at 13:22
  • No, frame rate is not synchronized with anything. It can vary, or even be 0 (CPU/GPU overload). It doesn't mean that nothing happens, it means that the frame isn't over and new frame won't begin until the current processes ends. Monitor frame rate has nothing to do with Flash. It has built in pipeline with predefined steps one after another, and the new frame will begin ONLY after the previous one is over. – Andrey Popov Apr 10 '14 at 13:47
  • So a new ENTER_FRAME will be issued only after all the processing for the current frame is finished, thanks for the info, but if all processing is done way before the end of each frame, will then the next frame try to start (by issuing ENTER_FRAME) in sync with the desktop refresh signal? – BEIC Apr 10 '14 at 15:15
  • (by "before the end of each frame" I meant, if the frame period is 16.7ms at 60fps and the cpu+gpu processing ends at e.g 8ms, while desktop refresh rate is 60fps) – BEIC Apr 10 '14 at 15:22
  • Yes, the new frame (ENTER_FRAME dispatched) will be ONLY after the current frame is finished. But no, if there are not enough 'tasks' for the current frame, new one won't start right away. That's why there is a `frameRate` setting, which tells how exactly frames will be there in a second. So if one is let's call it 'empty', the other will begin after specific amount of time. But if the frame execution is slow, the `frameRate` property will decrease. – Andrey Popov Apr 10 '14 at 15:27
  • Yes, but what I'm asking (my last question to clarify the whole process) is: Does flash try to sync its internal frame rate to the desktop's refresh rate -when the period is the same and it can? – BEIC Apr 10 '14 at 15:42
  • As I said it before - frame rate is not synchronized with anything. Never. :) Refresh rate of the monitor is a whole new universe, and Flash doesn't care bout it. It just tries to make tick exactly the same amount as the `frameRate` property is set. If it can't - it shows less. Otherwise - exactly the same. – Andrey Popov Apr 10 '14 at 15:44
  • Thanks for clarifying. I'm disappointed because if it was in sync, it would allow more possibilities... – BEIC Apr 10 '14 at 16:12
  • What do you need to do? There's a simple mechanism to decrease frame rate and use timer instead of frames, but it depends heavily on the reason why you need it :) – Andrey Popov Apr 10 '14 at 17:35