fix(jassub): [PKG-JASSUB-09] checkpoint hybrid canvas ownership and frame completion

This commit is contained in:
Harvey Zhao committed 2026-09-14 02:50:55 +08:00
1 parent b4b0276fe9
commit 7f185f698d
22 files changed
+18866 -37

No files matched your search

@@ -0,0 +1,11 @@
{
"task": "PKG-JASSUB-09",
"baselineCommit": "b4b0276fe9df13218ece21c3ba6a51b42948e16d",
"file": "packages/artplayer-plugin-jassub/src/jassub.es.js",
"originalSha256LF": "6a96af7914f702eb7d6303b466cbe16abddd278040f60cd29f153cdf60e92cb2",
"patchedSha256LF": "60590f2fca6ffded74f96f8a6001a86c32eb38f5e1fae26338cbbb43e93fb70a",
"patchFile": "refactor/baselines/jassub-hybrid.patch",
"patchSha256LF": "e1ff5591ea38fc66b46140458db93156c66aaaeceacb5ea433021cd8868651eb",
"predecessor": "refactor/baselines/jassub-offscreen-patch.json",
"purpose": "Release obsolete hybrid bitmaps before any render/scheduler/color-space effect while the display is offscreen; prevent public track calls from recreating canvas after hybrid destruction."
}
File diff suppressed because it is too large. Load diff
+27
View File
@@ -0,0 +1,27 @@
diff --git a/packages/artplayer-plugin-jassub/src/jassub.es.js b/packages/artplayer-plugin-jassub/src/jassub.es.js
index 6bd2bc2c6..88088b0ca 100644
--- a/packages/artplayer-plugin-jassub/src/jassub.es.js
+++ b/packages/artplayer-plugin-jassub/src/jassub.es.js
@@ -527,9 +527,9 @@ class o extends EventTarget {
}
// if the video or track changed, we need to re-attach the offscreen canvas
_reAttachOffscreen() {
- if (!this._offscreenRender || !this._ctx)
+ if (this._destroyed || !this._offscreenRender || !this._ctx)
return null;
- this._canvas.remove(), this._createCanvas(), this._canvasctrl = this._canvas.transferControlToOffscreen(), this._ctx = !1, this.sendMessage("offscreenCanvas", null, [this._canvasctrl]), this.resize(0, 0, 0, 0, !0);
+ this._canvas.remove(), this._createCanvas(), this._canvasctrl = this._canvas.transferControlToOffscreen(), this._ctx = !1, this.busy = !1, this._lastDemandTime = null, this.sendMessage("offscreenCanvas", null, [this._canvasctrl]), this.resize(0, 0, 0, 0, !0);
}
_updateColorSpace() {
if (this._destroyed || this._colorCallback != null) return;
@@ -559,6 +559,10 @@ class o extends EventTarget {
!e || !t || e !== t && (this._detachOffscreen(), this._ctx.filter = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='f'><feColorMatrix type='matrix' values='${f[e][t]} 0 0 0 0 0 1 0'/></filter></svg>#f")`);
}
_render({ images: e, asyncRender: t, times: s, width: r, height: n, colorSpace: a }) {
+ if (!this._ctx) {
+ for (const image of e) image.image?.close?.();
+ return;
+ }
this._unbusy(), this.debug && (s.IPCTime = Date.now() - s.JSRenderTime), (this._canvasctrl.width !== r || this._canvasctrl.height !== n) && (this._canvasctrl.width = r, this._canvasctrl.height = n, this._verifyColorSpace({ subtitleColorSpace: a })), this._ctx.clearRect(0, 0, this._canvasctrl.width, this._canvasctrl.height);
for (const i of e)
i.image && (t ? (this._ctx.drawImage(i.image, i.x, i.y), i.image.close()) : (this._bufferCanvas.width = i.w, this._bufferCanvas.height = i.h, this._bufferCtx.putImageData(new ImageData(this._fixAlpha(new Uint8ClampedArray(i.image)), i.w, i.h), 0, 0), this._ctx.drawImage(this._bufferCanvas, i.x, i.y)));