Skip to content

Instantly share code, notes, and snippets.

@jisungbin
Created July 22, 2022 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jisungbin/05ab3166a732853ead1d4ceecbc70b5a to your computer and use it in GitHub Desktop.
Save jisungbin/05ab3166a732853ead1d4ceecbc70b5a to your computer and use it in GitHub Desktop.

1. Compose 소개

  • 기존 UI 개발의 문제점

    왜 컴포즈를 써야 할까?

    • RoundImageView 만들기 위한 과정
    • 리사이클러뷰를 만들기 위한 과정
    • 상태 관리
    • 결론: UI 를 만들기 위한 모든 과정을 명시해야 해서 생산성이 저하된다.
  • Compose 로 리팩터링

    • RoundImageView 전/후 비교
    • 리사이클러뷰 전/후 비교
    • 상태 관리 전/후 비교
    • 결론: UI 를 만들기 위한 과정이 없다 → 생산성과 재사용성을 위해 컴포즈를 쓰자.

2. Compose 구성 요소

  • @Composable
    • 위치 메모이제이션
    • 컴포저블을 SlotTable 로 방출
  • SlotTable
    • Gap Buffer
  • Composition, Recomposition
    • Recomposition 속도: xml 에 비해 index 가 클수록 느려진다.
  • Snapshot System
    • MVCC 개념 빼고, Snapshot System 자체의 개념만 설명

3. How it works?

  • Compiler
    • 코드 정적 분석 및 기존 경고 억제
      • IDE Jetpack Compose 플러그인과 상호 작용
    • IR 생성
    • 클래스 안정성 추론
    • LiveLiteral 활성화
      • @NoLiveLiteral
    • 컴포저블 그룹 생성
      • Smart-Recomposition 활성화
        • @Composable 의 멱등성
  • Runtime
    • composing snapshot
    • Choreographer (Recomposer)
    • invalidations (recomposition process)

4. Compiler Debugging

  • build metrics
  • build reports

5. Best Practice

  • 리컴포지션 범위 줄이기
    • donut-hole skipping
    • Stability System
  • 리컴포지션 없애기
    • movableContentOf
    • @ReadOnlyComposable
    • @NoRestartableComposable
  • AOT 컴파일 활성화
    • Baseline Profiles

6. Wrap-up

  • 독립 버전 관리 체계 시작
  • 신규 API collectAsStateWithLifecycle
  • 읽어보면 좋을 자료
    • 컴포즈 분석하기 시리즈
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment