coderbhai
coderbhai

Reputation: 41

FPS Issue with Double vs. Triple Buffering in Android: How to Modify SurfaceFlinger Behaviour?

I am currently studying the Android 13 Emulator codebase and have encountered an issue related to how Unity-based games perform differently with double buffering versus triple buffering enabled in the Android environment.

Issue: When I enable triple buffering, the Unity game runs at 30 FPS. However, when I switch to double buffering, the FPS drops to around 20-23. I am aware that triple buffering introduces an additional buffer, which can increase latency, and I would prefer to use double buffering to maintain lower latency. However, the significant FPS drop with double buffering is problematic.

Objective: I aim to modify the SurfaceFlinger code in the AOSP (Android Open Source Project) to enable triple buffering but immediately composite the latest buffer queued by the app, similar to how double buffering behaves. This would allow me to maintain the target FPS without the additional latency typically associated with triple buffering.

Question:

  1. Could anyone provide insights into why this FPS drop occurs with double buffering compared to triple buffering in Unity games? [Keep in mind that the app is taking only 2 ms to render the frame, means all gl calls by the app finishes in 2 ms]
  2. In the SurfaceFlinger code, where should I implement changes to ensure that the latest buffer is composited as soon as queueBuffer is called by the app, even when triple buffering is enabled?

Any guidance or suggestions on the specific components or functions in SurfaceFlinger that I should focus on would be greatly appreciated.

Upvotes: 0

Views: 73

Answers (0)

Related Questions