Bug 1360

Summary: TextRenderer doesn't flush drawn text to GPU when backing texture fills up, ends up drawing incorrect text later
Product: [JogAmp] Jogl Reporter: Andy Edwards <jedwards>
Component: utilAssignee: Sven Gothel <sgothel>
Status: UNCONFIRMED ---    
Severity: normal    
Priority: P4    
Version: tbd   
Hardware: All   
OS: all   
Type: DEFECT SCM Refs:
Workaround: ---

Description Andy Edwards 2019-01-28 20:22:43 CET
I don't know for sure if this can happen, but based on my analysis of TextRenderer/GlyphCache/TextureBackingStoreManager/RectanglePacker it seems very likely.

It's possible to draw so many different characters within a single beginRendering()/endRendering() block that not even the maximum texture size could fit all of the glyphs.  Most of the drawn text will have already been flushed to the GPU because of the QuadRenderer filling up and automatically flushing, but the backing texture could fill up when the QuadRenderer is only half full.

When the glyph texture size is maxed out and it fills up, RectanglePacker calls manager.additionFailed, which fires a FAILURE event.  GlyphCache responds by clearing the cache and firing its own CLEAR event to TextRenderer, which only responds by calling glyphProducer.clearGlyphs().

The result is that any drawn text that hasn't been flushed to the GPU when the backing texture fills up won't get drawn properly.

To fix this, TextRenderer should flush() when the backing texture fills up, *before* the cache is cleared.