Refactor snapshot access between from cache and disk.
1. Correct the scope of the lock in SnapshotCache. The lock is now held from the snapshot cache to allow adding an extra reference if the snapshot is used outside the Window Manager lock. This ensures proper synchronization and prevents premature release of the snapshot. 2. Allows adding a reference for restored snapshots. Snapshots restored from disk can now also have an extra reference added. This enables quicker release of the associated hardware buffer, improving memory management. 3. Separates snapshot retrieval methods. The `getSnapshot` method is split into `FromDisk` and `FromCache` variants. This clarifies when the WM lock/Cache lock should be held, improving code readability and maintainability. Bug: 238206323 Bug: 379546318 Flag: com.android.window.flags.release_snapshot_aggressively Test: atest TaskSnapshotLowResDisabledTest TaskSnapshotCacheTest Test: Verify the snapshot load from disk can be released after parcel. Change-Id: I1982f1eb3fdf65d942c6bfae9ecee977984a222e
Loading
Please register or sign in to comment