EclipseEmu / eclipse-native

Eclipse, built as a native app for Apple platforms
3 stars 0 forks source link

[Video] Fast forward only renders frames when a view update occurs #24

Open magnetardev opened 4 months ago

magnetardev commented 4 months ago

This is going to be a bit of a weird one to debug.

On iOS (pre-18), fast forward runs as expected, utilizing effectively the same code. On macOS, however, frames are only rendered when view updates occur with fast forward on. I'm guessing the compositor will notify the game screen's NSView that a redraw needs to occur, but I'm not sure why it only happens in this context.

The way the frame timer is done should make sure that we're rendering at the same rate regardless of emulation speed, so I'm not sure why this would happen besides maybe thread oversaturation or something? (but if that were the case why is it happening on macOS and not iOS??)

One thing I can think of is me not calling waitUntilScheduled in the render step. Apple says to do so when drawing from a background thread, but it will block said thread until completion – which is far from ideal, especially since we're operating in tasks here, not threads. I'll need to test the cost of that more.

There's potentially this: https://forums.swift.org/t/task-not-released-fast-enough-after-its-execution/54594/5, but again, we're rendering at the same rate regardless of emulation speed.

https://github.com/EclipseEmu/eclipse-native/assets/25755297/f0087d42-0e0b-43ad-8f41-6987d2b5af57

magnetardev commented 3 months ago

This now impacts iOS 18 as well.

magnetardev commented 1 month ago

This is because I'm not doing a CATransaction.