mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Don't register a pending TextLayer
until render
is invoked (PR 18104 follow-up)
After the re-factoring in PR 18104 there's now a *theoretical* risk that a pending `TextLayer` is never removed, which we can avoid by not registering it until `render` is invoked. Note that this doesn't affect the viewer or tests, but if a third-party user calls `new TextLayer(...)` without a following call of either the `render`- or `cancel`-method we'd block global clean-up without this patch.
This commit is contained in:
parent
17e09e5478
commit
f2e7eee00e
1 changed files with 2 additions and 1 deletions
|
@ -122,7 +122,6 @@ class TextLayer {
|
|||
|
||||
setLayerDimensions(container, viewport);
|
||||
|
||||
TextLayer.#pendingTextLayers.add(this);
|
||||
// Always clean-up the temporary canvas once rendering is no longer pending.
|
||||
this.#capability.promise
|
||||
.catch(() => {
|
||||
|
@ -167,6 +166,7 @@ class TextLayer {
|
|||
}, this.#capability.reject);
|
||||
};
|
||||
this.#reader = this.#textContentSource.getReader();
|
||||
TextLayer.#pendingTextLayers.add(this);
|
||||
pump();
|
||||
|
||||
return this.#capability.promise;
|
||||
|
@ -423,6 +423,7 @@ class TextLayer {
|
|||
return;
|
||||
}
|
||||
this.#ascentCache.clear();
|
||||
|
||||
for (const { canvas } of this.#canvasContexts.values()) {
|
||||
canvas.remove();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue