Fix: Improve vis oom scores in split screen and desktop windowing.
Previously, visible applications in desktop windowing mode received a `vis` oom score, with their Z-index (`vis+X`) added to prioritize foreground apps. This was effective for single-window, single-process applications, making those above others less likely to be targeted by the Low Memory Killer Daemon (lmkd). However, this approach fell short for multi-window and multi-process applications (e.g., browsers). Without a direct mapping between an app's activities and its various processes, assigning a correct `vis+X` oom score to unfocused windows of an app with a focused window was impossible. This led to unexpected and suboptimal killing behavior. This change addresses the issue by laddering the oom scores of processes within the `vis` range based on their relative positions in the process LRU (Least Recently Used) list. The most recently used process now receives a `vis+0` score, and subsequent processes receive `vis+X` (where X is their position in the LRU). This leverages the existing mechanism where processes are moved to the top of the LRU list when focused, and allows applications to modify binding flags based on `onWindowFocusChanged` events, ensuring consistent and correct oom score assignments across all processes of a multi-window app. Bug: 421872956 Test: atest MockingOomAdjusterTests Flag: com.android.server.am.oomadjuster_vis_laddering Flag: com.android.server.am.remove_lru_spam_prevention Change-Id: Ie5436154bdd7423501ceb8f7d2118e6fdcfb0a61
Loading
Please register or sign in to comment