On Thu, 12 Nov 2026 16:00:22 GMT, Phil Race <[email protected]> wrote:

> Whilst this fix is probably fine, I'm not at all sure it relates to the bug 
> that it is being fixed under. Both cases should be allocating native memory, 
> not Java heap memory, and the memory usage would be similar. Perhaps FFM has 
> reclamation delays. And do you actually know that the reporters of this were 
> using massively long strings ? I mean the whole of War and Peace is only 
> about 3 million letters, and no one lays that out at once. I hope.

We don't know the reporters text, but you're right that a single shaping run 
should be of a gigantic size to lead to a minute long freeze.
There's a regression in JBR 25 that exacerbated this issue by causing newlines 
to split text into separate runs, so there's now another multiplier - number of 
runs and that causes a much faster growth. I think quite a normal (but long) 
log file may cause this. That regression is to be fixed within JBR, but the 
problem on OpenJDK side while rare to occur is still a real one, I think

> src/java.desktop/share/classes/sun/font/SunLayoutEngine.java line 72:
> 
>> 70:     // See hb_buffer_t::CONTEXT_LENGTH in hb-buffer.hh
>> 71:     // test/jdk/java/awt/font/TextLayout/ShapingContextTest.java checks 
>> the value in case of a future change.
>> 72:     private static final int HB_CONTEXT_LENGTH = 10;
> 
> FWIW this works as long as you are testing your bundled harfbuzz, but doesn't 
> guarantee what will be right on some end-user system with a different 
> harfbuzz.
> So could we not be more conservative, rather than being exact ?
> There seems to be minimal (no) benefit until the text gets very long anyway ..

True, I've measured a bit different numbers here, 1024 seems to be big enough 
but just as fast on realistic input (up to 500k)

-------------

PR Comment: https://git.openjdk.org/jdk/pull/33853#issuecomment-6917742247
PR Review Comment: https://git.openjdk.org/jdk/pull/33853#discussion_r4586322295

Reply via email to