Od 27 marca 2025 r. zalecamy używanie android-latest-release zamiast aosp-main do kompilowania i wspołtworzenia AOSP. Więcej informacji znajdziesz w artykule o zmianach w AOSP.
Nie sygnalizowane blokowanie bufora za pomocą AutoSingleLayer
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Android 13 dodaje nową konfigurację o nazwie AutoSingleLayer, która służy do blokowania niesygnalizowanych buforów. Ta konfiguracja umożliwia SurfaceFlingerowi blokowanie niezapowiadanego bufora, gdy aktualizowana jest tylko jedna warstwa, a nie w przypadkach, które występują na różnych warstwach, takich jak zmiany geometrii czy transakcje synchronizacji.
Przed Androidem 13 flaga debug.sf.latch_unsignaled w AOSP pozwalała usługom SurfaceFlinger przechwytywać wszystkie niesygnalizowane bufory niezależnie od przypadku użycia. Po włączeniu tej konfiguracji mogą wystąpić niepożądane skutki uboczne, takie jak przerywanie transakcji synchronizacji i zawieszanie całego wyświetlacza podczas oczekiwania na niekompletne bufory.
W trybie AutoSingleLayer aktualizowany jest tylko bufor pojedynczej powierzchni w ramce. Tryb ten umożliwia korzystanie z buforów bez sygnalizacji w przypadku gier i innych aplikacji pełnoekranowych, a także ogranicza zacięcia aplikacji, nie wpływając na wyświetlacz.
Ustawienia trybu AutoSingleLayer
W Androidzie 13 domyślnym trybem funkcji bufora z niesygnalizowanym buforem jest AutoSingleLayer. Ten tryb jest kontrolowany przez właściwość systemową debug.sf.auto_latch_unsignaled.
SurfaceFlinger odczytuje LatchUnsignaledConfig podczas uruchamiania.
Możliwe konfiguracje:
LatchUnsignaledConfig::AutoSingleLayer
W tym trybie domyślnym AOSP blokowanie niesygnalizowanych buforów jest dozwolone, gdy w ramce jest aktualizowana pojedyncza warstwa, a aktualizacja obejmuje tylko aktualizację bufora bez transakcji synchronizacji ani zmian geometrii. W tym trybie parametr debug.sf.auto_latch_unsignaled jest domyślnie ustawiony na true.
LatchUnsignaledConfig::Disabled
W tym trybie wyłączone jest zachowanie blokady bez sygnału, a blokada dotyczy tylko transakcji z sygnałem. Ten tryb wyłącza też tryb AutoSingleLayer. Aby skonfigurować ten tryb, ustaw debug.sf.latch_unsignaled i debug.sf.auto_latch_unsignaled na false.
LatchUnsignaledConfig::Always
W tym trybie wszystkie bufory są blokowane bez sygnalizacji. Aby skonfigurować ten tryb, ustaw wartość debug.sf.latch_unsignaled na true.
Test AutoSingleLayer
Aby sprawdzić, czy bufor jest zablokowany bez sygnału, poszukaj tych śladów w SurfaceFlinger w Perfetto:
Rysunek 1. Ślad zablokowanego niesygnalizowanego bufora w Perfetto
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-27 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-27 UTC."],[],[],null,["# Unsignaled buffer latching with AutoSingleLayer\n\nAndroid 13 adds a new configuration called\n[`AutoSingleLayer`](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/android16-release/services/surfaceflinger/SurfaceFlinger.h#160) for latching\nunsignaled buffers. This configuration lets SurfaceFlinger latch an unsignaled\nbuffer when only a single layer is updating, and not for the cases that occur\nacross layers, such as geometry changes or sync transactions.\n\nBefore Android 13, the `debug.sf.latch_unsignaled` flag\nin AOSP lets SurfaceFlinger latch all unsignaled buffers, regardless of the use\ncase. When this configuration is enabled, there are undesired side effects, such\nas breaking sync transactions and freezing the entire display while waiting on\nincomplete buffers.\n\nWith the `AutoSingleLayer` mode, only a buffer of a single surface is updated\nin a frame. This mode enables games and other fullscreen apps to get the benefit\nof latching unsignaled buffers and reducing app jank while remaining unaffected\nby display freezes.\n\nAutoSingleLayer mode settings\n-----------------------------\n\nIn Android 13,\n[`AutoSingleLayer`](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/android16-release/services/surfaceflinger/SurfaceFlinger.h#160) is the default\nmode for the latch unsignaled buffer feature. This mode is controlled by the\nsystem property [`debug.sf.auto_latch_unsignaled`](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/android16-release/services/surfaceflinger/SurfaceFlinger.cpp#454).\n\nSurfaceFlinger reads [`LatchUnsignaledConfig`](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/android16-release/services/surfaceflinger/SurfaceFlinger.cpp#449) on boot.\nHere are the possible configurations:\n\n- `LatchUnsignaledConfig::AutoSingleLayer`\n\n In this AOSP default mode, latching unsignaled buffers is permitted when a\n single layer is updated in a frame, and the update includes just a buffer\n update with no sync transactions or geometry changes. In this mode, [`debug.sf.auto_latch_unsignaled`](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/android16-release/services/surfaceflinger/SurfaceFlinger.cpp#454)\n is set to `true` by default.\n- `LatchUnsignaledConfig::Disabled`\n\n This mode disables the latch unsignaled behavior and latches only signaled\n transactions. This mode also disables the `AutoSingleLayer` mode. To\n configure this mode, set [`debug.sf.latch_unsignaled`](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/android16-release/services/surfaceflinger/SurfaceFlinger.cpp#450) and\n [`debug.sf.auto_latch_unsignaled`](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/android16-release/services/surfaceflinger/SurfaceFlinger.cpp#454) to `false`.\n- `LatchUnsignaledConfig::Always`\n\n In this mode, all buffers are latched unsignaled. To configure this mode, set\n [`debug.sf.latch_unsignaled`](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/android16-release/services/surfaceflinger/SurfaceFlinger.cpp#450) to `true`.\n | **Note:** This mode takes priority over setting `AutoSingleLayer` but can cause display freezing and other undesired effects. This mode might be deprecated in future releases.\n\nTest `AutoSingleLayer`\n----------------------\n\nTo test whether a buffer is latched unsignaled, look for the following traces\nfrom SurfaceFlinger in [Perfetto](https://developer.android.com/topic/performance/tracing):\n\n**Figure 1.** Trace of a latched unsignaled buffer in Perfetto"]]