Open
fix(Text): release cached font collection when no surfaces remain #3885
you_yang_Add on 20 hours ago
fix(Text): release cached font collection when no surfaces remain #3885
Open
Merge blocked
20 hours ago Added label: bug
20 hours ago Associated issue: [0.72-main] Cached font collection stays resident after all surfaces are closed
20 hours ago Associated issue: [0.72-main] Cached font collection stays resident after all surfaces are closed
20 hours ago Added label: AI检视中
you_yang_
20 hours ago Comments:
20 hours ago Comments:
start build


openharmony_ci
20 hours ago Comments:
20 hours ago Comments:
感谢提交 Pull Requests!
Thanks for submitting a pull request.


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


20 hours ago Removed label: AI检视中
20 hours ago Added label: AI已检视
20 hours ago Added label: 编译成功
20 hours ago Added label: 静态检查成功
20 hours ago Test passed
openharmony_ci
20 hours ago Comments:
20 hours ago Comments:
代码门禁通过
您可以通过如下链接查看门禁报告: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).