已开启
fix(Text): release cached font collection when no surfaces remain #3885
you_yang_创建于 1 天前
fix(Text): release cached font collection when no surfaces remain #3885
已开启
合并受阻
1 天前 添加了label:bug
1 天前 关联了issue:[0.72-main] Cached font collection stays resident after all surfaces are closed
1 天前 关联了issue:[0.72-main] Cached font collection stays resident after all surfaces are closed
1 天前 添加了label:AI检视中
you_yang_
1 天前 评论:
1 天前 评论:
start build


openharmony_ci
1 天前 评论:
1 天前 评论:
感谢提交 Pull Requests!
Thanks for submitting a pull request.


1 天前 添加了label:dco检查成功
openharmony_ci
1 天前 评论:
1 天前 评论:
首次触发
门禁构建开始,包含静态检查、代码编译【rnoh_0.72-main编译】,预计在60分钟内完成,门禁结果会同步发送到注册邮箱。您可以通过如下链接跟踪门禁进展:http://dcp.openharmony.cn/workbench/cicd/detail/6aeda83e64650f998ba95499/runlist


1 天前 删除了label:AI检视中
1 天前 添加了label:AI已检视
1 天前 添加了label:编译成功
1 天前 添加了label:静态检查成功
1 天前 通过测试
openharmony_ci
1 天前 评论:
1 天前 评论:
代码门禁通过
您可以通过如下链接查看门禁报告:http://dcp.openharmony.cn/workbench/cicd/detail/6aeda83e64650f998ba95499/runlist
静态检查:
| # | check type | result | report |
|---|---|---|---|
| 1 | codeCheck | pass | >>> |
编译测试:
| # | Device | build result | package |
|---|---|---|---|
| 1 | rnoh_0.72-main | success | >>> |


锘縋artial backport of #3860 to
0.72-main(font-collection release only). Linked issue: #3535Problem
On this branch
TextMeasureritself caches theOH_Drawing_FontCollectionused for text measurement (there is no separateFontRegistry). When an app closes all RN surfaces while keeping the RNInstance alive, the cached collection stays resident on the native heap until instance teardown.Scope
This is a reduced backport of #3860: on this branch the per-instance text measurement entry caches live in the global
TextMeasureRegistryshared across instances, so trimming them from one instance's lifecycle would affect other instances. This change therefore only releases the per-instance cached font collection and leaves the global registry untouched.Solution
TextMeasurer: addreleaseCachedFontCollection()dropping only the measurer's cached reference under its mutex; registered font bytes are kept, so the nextgetFontCollection()rebuilds the collection lazily (same behavior as the existingregisterFontreplacement path). The underlyingOH_Drawing_FontCollectionis destroyed via its registeredOH_Drawing_DestroyFontCollectiondeleter once the last reference goes away.RNInstanceInternal: addreleaseCachedFontCollection()forwarding to the measurer from the context container (findon the"textLayoutManagerDelegate"key), and call it inmarkSelfAboutToDestroyed().RNInstanceCAPI: callreleaseCachedFontCollection()indestroySurface()when the last surface is removed. NocreateSurface()hook is needed: the collection is rebuilt lazily on the next measurement.The host gtest additions of #3860 are not ported because this branch has no host gtest infrastructure; the release logic mirrors the
FontRegistry::releaseCachedFontCollection()implementation covered byrnoh_font_teston main.Impact
Internal lifecycle management only; no public API, symbol or behavior difference for surfaces that stay open. Typography consumers holding shared_ptr copies of the collection are unaffected - releasing only drops the measurer's cached reference.
Test
rnoh_font_test(PR #3860).