在 Compose 中對重組偵錯
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
瞭解如何在 Jetsnack 中偵錯效能問題,以及如何在 Compose 中修正問題。瞭解為何使用 lambda 延後狀態讀取,可略過組合。
重點
- Compose 的三個階段分別是組合、版面配置和繪圖。
- 如果沒有任何變更,Compose 可以略過階段。有時 Compose 會完全略過組合,以便提升效能。
- 您可以使用 lambda 修飾符略過組合。
- 略過重組作業有助於減少捲動期間的卡頓情形。
- Android Studio 的版面配置檢查器是一項實用工具,可協助您偵錯重組問題。
資源
包含此指南的集合
本指南是精選的快速指南系列之一,涵蓋更廣泛的 Android 開發目標:
Compose 基礎
本系列影片將介紹各種 Compose API,快速向您展示可用的 API 和使用方式。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-02-06 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-02-06 (世界標準時間)。"],[],[],null,["# Debugging recomposition in Compose\n\n\u003cbr /\u003e\n\nA look into debugging a performance issue in Jetsnack and how to fix it in\nCompose. Learn why deferring state reads by using a lambda means composition can\nbe skipped. \n\nKey points\n----------\n\n- The three phases of Compose are composition, layout, and draw.\n- Compose can skip a phase if nothing has changed. Sometimes Compose will entirely skip composition to optimize performance.\n- You can use a lambda modifier can skip composition.\n- Skipping recomposition can help reduce jank during scrolling.\n- The Layout Inspector in Android Studio is a good tool to help you debug recomposition issues.\n\nResources\n---------\n\n- [Blog post](https://goo.gle/3TRm8wv)\n- [Jetsnack on GitHub](https://goo.gle/3D3NCJl)\n\nCollections that contain this guide\n-----------------------------------\n\nThis guide is part of these curated Quick Guide collections that cover\nbroader Android development goals: \n\n### Compose basics\n\nThis series of videos introduces various Compose APIs, quickly showing you what's available and how to use them. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/compose-basics) \n\nHave questions or feedback\n--------------------------\n\nGo to our frequently asked questions page and learn about quick guides or reach out and let us know your thoughts. \n[Go to FAQ](/quick-guides/faq) [Leave feedback](https://issuetracker.google.com/issues/new?component=1573691&template=1993320)"]]