-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Move getContext call to InternalRenderTask #20016
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
2027870
to
f89b738
Compare
f89b738
to
680988d
Compare
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/e6ca5fca607aefc/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/80c5eb5c6660194/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/e6ca5fca607aefc/output.txt Total script time: 28.18 mins
Image differences available at: http://54.241.84.105:8877/e6ca5fca607aefc/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/80c5eb5c6660194/output.txt Total script time: 52.70 mins
Image differences available at: http://54.193.163.58:8877/80c5eb5c6660194/reftest-analyzer.html#web=eq.log |
src/display/api.js
Outdated
@@ -1404,7 +1404,7 @@ class PDFPageProxy { | |||
* resolved when the page finishes rendering. | |||
*/ | |||
render({ | |||
canvasContext, | |||
canvas, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this an API-breaking change? If so, this patch should either be labeled as [api-minor]
with a working fallback and deprecation warning, or as [api-major]
if no sensible fallback can be used here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was indeed, which is also why we had all the test breakage. I think with my latest update now some of the test changes can indeed be reverted if you prefer I do that. That said, I made a change that would allow the change to not be breaking (set the default value of canvas
to canvasContext.canvas
and continue to accept canvasContext
).
19bf452
to
755099d
Compare
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/9ee77ced85e7946/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/425d8c04b161167/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/425d8c04b161167/output.txt Total script time: 30.61 mins
|
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/9ee77ced85e7946/output.txt Total script time: 58.29 mins
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looks good, but I'd like to have a final look after the comments are addressed just to make sure I didn't miss anything because this involves a (now fortunately non-breaking, so thanks for that!) API change.
src/display/api.js
Outdated
* @property {CanvasRenderingContext2D} canvasContext - A 2D context of a DOM | ||
* Canvas object. | ||
* @property {CanvasRenderingContext2D} canvasContext - An optional | ||
* CanvasRenderingContext2D for backwards compatibility. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should indicate the replacement option here so that users know what to migrate towards. I would suggest "canvasContext - Deprecated 2D context of a DOM Canvas object for backwards compatibility; use the canvas
parameter instead."
src/display/api.js
Outdated
* @property {CanvasRenderingContext2D} canvasContext - An optional | ||
* CanvasRenderingContext2D for backwards compatibility. | ||
* @property {HTMLCanvasElement} canvas - A DOM Canvas object the default value | ||
* is the canvas associated with the canvasContext paramter above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"canvas - A DOM Canvas object. The default value is the canvas associated with the canvasContext
parameter if no value is provided explicitly." (fixes the paramter
typo and makes it a bit easier to read)
src/display/api.js
Outdated
@@ -3131,7 +3146,8 @@ class InternalRenderTask { | |||
this._continueBound = this._continue.bind(this); | |||
this._scheduleNextBound = this._scheduleNext.bind(this); | |||
this._nextBound = this._next.bind(this); | |||
this._canvas = params.canvasContext.canvas; | |||
this._canvas = params.canvas; | |||
this.enableHWA = enableHWA; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this.enableHWA
private here (so this._enableHWA
) too to limit the API surface, or is it used in the public API somewhere?
@@ -4939,7 +4939,7 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`) | |||
viewport.height | |||
); | |||
const renderTask = page.render({ | |||
canvasContext: canvasAndCtx.context, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a new test that deliberately uses the legacy canvasContext
to keep coverage for it until it's eventually removed, to avoid regressions in that code path.
This is a precursor to moving the call into a worker thread to let us use `OffscreenCanvas`. The current position wouldn't work since we make transformations to the canvas object after the getContext call, which isn't allowed for OffscreenCanvas. Also it isn't allowed to clone or `transferControlToOffscreen` the canvas after the `getContext` call.
755099d
to
0dd8b9c
Compare
Thanks for the review and the suggestions @timvandermeij. Let me know if you think the test should suffice or if I should |
Move the
getContext
call out of_createContext
and intoInternalRenderTask#initializeGraphics
and adapt tests accordingly.This is a precursor to moving the call into a worker thread to let us use
OffscreenCanvas
. The current position wouldn't work since we make transformations to the canvas object after thegetContext
call, which isn't allowed forOffscreenCanvas
. Also it isn't allowed to clone ortransferControlToOffscreen
the canvas after thegetContext
call.