diff --git a/CHANGELOG.md b/CHANGELOG.md index 6318a22cf..1633fde3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed -- +- Adjusted the `FontCache` font timeout to 400 ms and makes it configurable as a static `FontCache.FONT_TIMEOUT`. This is to help prevent a downward spiral on mobile devices that might take a long while to render a few starting frames causing the cache to repeatedly clear and never recover. ### Updates diff --git a/src/engine/Graphics/FontCache.ts b/src/engine/Graphics/FontCache.ts index fd7c466ea..3ec165d1a 100644 --- a/src/engine/Graphics/FontCache.ts +++ b/src/engine/Graphics/FontCache.ts @@ -5,6 +5,7 @@ import { Font } from './Font'; import { FontTextInstance } from './FontTextInstance'; export class FontCache { + public static FONT_TIMEOUT = 500; private static _LOGGER = Logger.getInstance(); private static _TEXT_USAGE = new Map(); private static _TEXT_CACHE = new Map(); @@ -41,7 +42,7 @@ export class FontCache { const currentHashCodes = new Set(); for (const [textInstance, time] of FontCache._TEXT_USAGE.entries()) { // if bitmap hasn't been used in 100 ms clear it - if (time + 100 < performance.now()) { + if (time + FontCache.FONT_TIMEOUT < performance.now()) { FontCache._LOGGER.debug(`Text cache entry timed out ${textInstance.text}`); deferred.push(textInstance); textInstance.dispose();