From 608d78b6ac2f48fc34269e1a70b82af6cf031ef9 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sat, 15 Sep 2018 09:46:19 -0700 Subject: [PATCH] Add fallback for window.createImageBitmap --- src/renderer/atlas/DynamicCharAtlas.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/renderer/atlas/DynamicCharAtlas.ts b/src/renderer/atlas/DynamicCharAtlas.ts index a00bb472..4516524f 100644 --- a/src/renderer/atlas/DynamicCharAtlas.ts +++ b/src/renderer/atlas/DynamicCharAtlas.ts @@ -10,6 +10,7 @@ import BaseCharAtlas from './BaseCharAtlas'; import { DEFAULT_ANSI_COLORS } from '../ColorManager'; import { clearColor } from '../../shared/atlas/CharAtlasGenerator'; import LRUMap from './LRUMap'; +import { isFirefox, isSafari } from '../../shared/utils/Browser'; // In practice we're probably never going to exhaust a texture this large. For debugging purposes, // however, it can be useful to set this to a really tiny value, to verify that LRU eviction works. @@ -286,6 +287,14 @@ export default class DynamicCharAtlas extends BaseCharAtlas { } private _queueGenerateBitmap(): void { + // Support is patchy for createImageBitmap at the moment, pass a canvas back + // if support is lacking as drawImage works there too. Firefox is also + // included here as ImageBitmap appears both buggy and has horrible + // performance (tested on v55). + if (!('createImageBitmap' in context) || isFirefox || isSafari) { + return; + } + // Check if it's already queued if (this._bitmapCommitTimeout !== null) { return; @@ -296,7 +305,6 @@ export default class DynamicCharAtlas extends BaseCharAtlas { private _generateBitmap(): void { const countAtGeneration = this._glyphsWaitingOnBitmapCount; - // TODO: Fallback when createImageBitmap not supported window.createImageBitmap(this._cacheCanvas).then(bitmap => { // Set bitmap this._bitmap = bitmap;