Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ff44bbc authored by Austin Borger's avatar Austin Borger
Browse files

CameraService: Consider pids before priority when evicting a client.

We are occasionally seeing differences in priority scores for the same
pid when a process tries to open a second camera (or the same one twice
without closing it). While this is a problem by itself, checking the pid
before the priority scores would ensure the correct behavior for
consecutive calls to opening the camera (closing the first camera
connection and opening up a second one). This is especially true for
cases where oomScoreOffset is nonzero, since it will only be considered
for the new client.

Bug: 233743526
Test: Ran custom cameraservice_test before and after fix.
Change-Id: Ie6b678681d1141e077670e627f9c4244fbdf1287
parent 866b6639
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -527,12 +527,7 @@ ClientManager<KEY, VALUE, LISTENER>::wouldEvictLocked(
        if (!returnIncompatibleClients) {
        if (!returnIncompatibleClients) {
            // Find evicted clients
            // Find evicted clients


            if (conflicting && curPriority < priority) {
            if (conflicting && owner == curOwner) {
                // Pre-existing conflicting client with higher priority exists
                evictList.clear();
                evictList.push_back(client);
                return evictList;
            } else if (conflicting && owner == curOwner) {
                // Pre-existing conflicting client with the same client owner exists
                // Pre-existing conflicting client with the same client owner exists
                // Open the same device twice -> most recent open wins
                // Open the same device twice -> most recent open wins
                // Otherwise let the existing client wins to avoid behaviors difference
                // Otherwise let the existing client wins to avoid behaviors difference
@@ -546,6 +541,11 @@ ClientManager<KEY, VALUE, LISTENER>::wouldEvictLocked(
                    evictList.push_back(client);
                    evictList.push_back(client);
                    return evictList;
                    return evictList;
                }
                }
            } else if (conflicting && curPriority < priority) {
                // Pre-existing conflicting client with higher priority exists
                evictList.clear();
                evictList.push_back(client);
                return evictList;
            } else if (conflicting || ((totalCost > mMaxCost && curCost > 0) &&
            } else if (conflicting || ((totalCost > mMaxCost && curCost > 0) &&
                    (curPriority >= priority) &&
                    (curPriority >= priority) &&
                    !(highestPriorityOwner == owner && owner == curOwner))) {
                    !(highestPriorityOwner == owner && owner == curOwner))) {