Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release thay vì aosp-main để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Khóa vùng đệm không có tín hiệu bằng AutoSingleLayer
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Android 13 thêm một cấu hình mới có tên là AutoSingleLayer để khoá các vùng đệm không được báo hiệu. Cấu hình này cho phép SurfaceFlinger khoá một vùng đệm không được báo hiệu khi chỉ một lớp duy nhất đang cập nhật, chứ không phải cho các trường hợp xảy ra trên các lớp, chẳng hạn như thay đổi hình học hoặc giao dịch đồng bộ hoá.
Trước Android 13, cờ debug.sf.latch_unsignaled trong AOSP cho phép SurfaceFlinger khoá tất cả vùng đệm không được báo hiệu, bất kể trường hợp sử dụng. Khi bật cấu hình này, sẽ có các hiệu ứng phụ không mong muốn, chẳng hạn như phá vỡ các giao dịch đồng bộ hoá và làm treo toàn bộ màn hình trong khi chờ các vùng đệm chưa hoàn tất.
Với chế độ AutoSingleLayer, chỉ một vùng đệm của một nền tảng duy nhất được cập nhật trong một khung. Chế độ này cho phép các trò chơi và ứng dụng toàn màn hình khác tận dụng lợi ích của việc khoá các vùng đệm không được báo hiệu và giảm hiện tượng giật ứng dụng mà không bị ảnh hưởng bởi tình trạng màn hình bị treo.
Chế độ cài đặt AutoSingleLayer
Trong Android 13, AutoSingleLayer là chế độ mặc định cho tính năng vùng đệm không được báo hiệu của chốt. Chế độ này do thuộc tính hệ thống debug.sf.auto_latch_unsignaled kiểm soát.
SurfaceFlinger đọc LatchUnsignaledConfig khi khởi động.
Sau đây là các cấu hình có thể xảy ra:
LatchUnsignaledConfig::AutoSingleLayer
Ở chế độ mặc định AOSP này, việc khoá các vùng đệm không được báo hiệu được cho phép khi một lớp duy nhất được cập nhật trong một khung và bản cập nhật chỉ bao gồm một bản cập nhật vùng đệm mà không có giao dịch đồng bộ hoá hoặc thay đổi hình học. Ở chế độ này, debug.sf.auto_latch_unsignaled được đặt thành true theo mặc định.
LatchUnsignaledConfig::Disabled
Chế độ này tắt hành vi không báo hiệu của chốt và chỉ báo hiệu các giao dịch chốt. Chế độ này cũng tắt chế độ AutoSingleLayer. Để định cấu hình chế độ này, hãy đặt debug.sf.latch_unsignaled và debug.sf.auto_latch_unsignaled thành false.
LatchUnsignaledConfig::Always
Ở chế độ này, tất cả vùng đệm đều được khoá không có tín hiệu. Để định cấu hình chế độ này, hãy đặt
debug.sf.latch_unsignaled thành true.
Kiểm thử AutoSingleLayer
Để kiểm tra xem một vùng đệm có được khoá không báo hiệu hay không, hãy tìm các dấu vết sau từ SurfaceFlinger trong Perfetto:
Hình 1. Dấu vết của bộ đệm không được báo hiệu trong Perfetto
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 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"]]