Skip to content

Releases: donglua/FastInflater

v0.5.1

22 May 09:43

Choose a tag to compare

更新内容

修复

  • 修复复用 View 时父容器 LayoutParams 应用不正确的问题,避免从池中取出的 View 在不同父容器场景下沿用不兼容布局参数。

文档

  • README 引入示例更新为 JitPack tag 版本:v0.5.1

使用方式

implementation("com.github.donglua:FastInflater:v0.5.1")

v0.5.0

22 May 06:28

Choose a tag to compare

更新内容

新增

  • 增加生命周期敏感布局池化控制能力,可按 layout 关闭池化,避免带有宿主生命周期或监听注册的 View 被错误复用。
  • 支持自定义 View 自清理:自定义 View 可实现回收清理逻辑,降低池化复用后的脏状态风险。
  • 增加 WarmUpFallbackClassifier,用于识别需要主线程处理的布局,并在预热异常时安全降级。

修复与优化

  • 优化 View 池管理与主线程布局处理机制。
  • 修复从池中取出 View 时 LayoutParams 兼容性检查不完整的问题。
  • 修复 obtain 取到不兼容 View 时未正确保留/处理的问题。

测试

  • 补充核心模块单元测试,覆盖池化、回收、兼容性和主线程降级相关行为。

使用方式

implementation("com.github.donglua:FastInflater:v0.5.0")

FastInflater 0.4.0

22 May 02:48

Choose a tag to compare

Highlights

  • Add FastInflaterRecycler as the recommended RecyclerView creation-side warmup API.
  • Reposition FastInflater as an Android XML layout diagnostics and runtime view-pooling optimization tool.
  • Remove Phase 2 codegen remnants and keep the library focused on lightweight runtime pooling.

Performance

  • Make the default pool key a lightweight Long based on layoutId.
  • Keep factory isolation optional to avoid Context/LayoutInflater access on the default hot path.
  • Move default View cleanup to the recycle path so pool hits avoid recursive View tree cleanup.
  • Add runtime switches for diagnostic metrics to avoid timing/stat writes after tuning.
  • Add warmUp capacity reservation to avoid inflating views that cannot enter the pool.
  • Add generation checks so stale warmUp work cannot refill the pool after clear/trim operations.

Fixes

  • Fix DataBinding pool hit semantics so only successful rebinds count as hits.
  • Change LayoutStat.totalMs and maxMs to Long getters and update demo usage.
  • Reuse the main handler in async fallback paths.

Verification

  • git diff --check
  • ./gradlew :lib:compileDebugKotlin :demo:compileDebugKotlin :lib:publishReleasePublicationToMavenLocal
  • GitHub Actions CI passed.
  • GitHub Packages publish workflow passed.

v0.3.0

22 May 02:53

Choose a tag to compare

FastInflater v0.3.0

修复包含 ComposeView / WebView / LiveData 等主线程依赖组件的布局在后台 warmUp 时崩溃的问题。

Bug Fixes

  • 修复后台 inflate 抛 Cannot invoke removeObserver on a background thread 等主线程依赖异常时不会 crash,自动降级到主线程 IdleHandler
  • 失败的布局自动加入 main-thread-only 集合,后续 warmUp 和 inflateAsync 直接走主线程
  • inflateAsync 失败时保证回调一定被调用(fallback 主线程重新 inflate)

New APIs

  • FastInflater.markAsMainThreadOnly(layoutId) — 显式标记布局只能主线程 inflate(推荐预先标记已知含 ComposeView 的布局)
  • FastInflater.isMainThreadOnly(layoutId) — 查询布局是否被标记
  • FastInflater.setWarmUpListener(listener) — 监控降级事件,便于诊断

Usage

// 预先标记
FastInflater.get().markAsMainThreadOnly(R.layout.fragment_compose_view)

// 监听降级
FastInflater.get().setWarmUpListener(object : ViewPool.WarmUpListener {
    override fun onMarkedAsMainThreadOnly(layoutId: Int) {
        Log.w("FastInflater", "main-thread-only: ${resources.getResourceEntryName(layoutId)}")
    }
})
implementation("com.github.donglua:FastInflater:0.3.0")

v0.2.0

21 May 08:28

Choose a tag to compare

FastInflater v0.2.0

Breaking Changes

  • 包名从 com.aspect.fastinflater 迁移至 com.github.donglua.fastinflater,使用方需更新 import

引入

// settings.gradle.kts
maven { url = uri("https://jitpack.io") }

// build.gradle.kts
implementation("com.github.donglua:FastInflater:0.2.0")

New Features

  • Phase 2 codegen 属性扩充 — 支持 orientation, padding, margin, weight, textSize, textStyle, gravity, src, contentDescription,item_feed.xml 可完整生成
  • LayoutParams 智能选择 — 根据父容器自动使用 LinearLayout.LayoutParams / MarginLayoutParams
  • dp/sp 运行时转换 — codegen 生成 TypedValue.applyDimension 调用,适配不同屏幕密度

Bug Fixes

  • 修复 FastRecycledViewPool 双池复用冲突(同一 View 不再被两个池同时持有)
  • 修复 ViewCleaner 清除 view.tag 导致 DataBinding 失效的问题
  • R 类引用通过 rPackage 参数正确解析,codegen 输出可编译

环境要求

  • minSdk 24 / Kotlin 1.9+ / AndroidX

v0.1.0

21 May 06:58

Choose a tag to compare

FastInflater v0.1.0

Phase 1 完整发布,零构建侵入的 LayoutInflater 性能优化方案。

引入

// settings.gradle.kts
maven { url = uri("https://jitpack.io") }

// build.gradle.kts
implementation("com.github.donglua:FastInflater:0.1.0")

核心特性

  • View 池化复用,池命中时 inflate 耗时降至 0
  • IdleHandler 智能预热,不抢占用户交互帧
  • 异步 inflate,单线程模型保证线程安全
  • 纳秒级耗时追踪,精确识别热点布局
  • PoolStats 命中率监控,指导调优决策
  • autoTune 自适应池大小,高频布局池大、低频池小
  • FastRecycledViewPool 一行代码对接 RecyclerView
  • FastDataBinding 兼容 DataBinding 池化复用
  • ViewRecyclePolicy 自定义回收策略
  • Configuration 变化 / 内存压力自动清池

环境要求

  • minSdk 24
  • Kotlin 1.9+
  • AndroidX