You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
High memory use when parsing some WOFF2 fonts. #298
I work at Xperi. We are Chromium integrators that target embedded devices where memory is more sparse than on desktop/mobile. We've noticed that OTS can use a substantial amount of memory while parsing some large and compressed WOFF2 fonts.
We traced this down to the fact that the interface of OTSContext::Process requires holding more than two memory buffers at once while processing WOFF2 fonts, as the input buffer can't be deleted once it is no longer needed - specifically after the buffer has been decompressed. Consider this interface:
The input buffer, data, is both const declared and of different type than output meaning the input buffer can't be destroyed or re-used internally. This leads to a need to hold three buffers in memory simultaneously while processing compressed WOFF2 fonts.
It would be possible to make OTSContext::Process use less memory for this usecase if an additional overload was added where ownership of the input buffer could be transferred to OTSContext::Process. Something along the lines of:
ots::ExpandingMemoryStream Process(
ots::ExpandingMemoryStream&& input, uint32_t index = -1);
Activity