-
Notifications
You must be signed in to change notification settings - Fork 60
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
faster offscreen canvas #122
Comments
Merged in the commit above, still TODO:
|
After fixing a few minor issues, I see a bigger problem: the offscreen decoder paints all screen updates in the order they are decoded and not the order they are submitted which causes visual corruption, in particular with Fixing these problems may well cost us some of the performance gains. Ideas:
|
New items:
|
as long as the packet is valid for the current flush sequence
images may be in the process of being decoded when the window is destroyed, just drop the screen update
makes the code more re-usable, the window now controls the canvas element rather than being given one by the client, the extra canvas objects are no longer defined when using the new offscreen worker
one is a paint packet option, the other one is a sequence number
Here are some other things that I wanted to look into but I am running out of time:
At some point in the (hopefully short term) future, packet loss from #143 will require some interesting changes to the paint code... which will need some help from the server to make it easier to handle. |
so we can choose not to use the back buffer
More thoughts on
--- a/html5/js/OffscreenDecodeWorker.js
+++ b/html5/js/OffscreenDecodeWorker.js
@@ -37,7 +37,6 @@ class WindowDecoder {
}
init() {
this.back_buffer = null;
- this.init_back_buffer();
this.image_decoder = this.new_image_decoder();
this.video_decoder = this.new_video_decoder();
this.flush_seqs = []; //this is the sequence numbers of the flush packets
@@ -300,6 +299,7 @@ class WindowDecoder {
paint_box();
}
else if (coding == "scroll") {
+ this.init_back_buffer();
for (let i = 0, j = data.length; i < j; ++i) {
const scroll_data = data[i];
const sx = scroll_data[0],
@@ -368,6 +368,7 @@ class WindowDecoder {
const ctx = this.canvas.getContext("2d");
ctx.imageSmoothingEnabled = false;
ctx.drawImage(this.back_buffer, 0, 0);
+ this.back_buffer = null;
}
}
The performance is much better though, since we avoid a copy.
Are we missing a call to OffScreenContext.commit() Edit: merged below, the patch above was painting the wrong buffer! |
take a snapshot of the canvas when it stops updating
'scroll' should always be processed first - it was already the case because of the insertion order, but this change makes it explicit
Let's close this. Also: echo timing (vs waiting vsync), restore encodings validation, etc. |
keep compressed packets only and decompress when we need them
Cranking Up Performance in Graphics Intensive Web Apps and Games (Google I/O '17)
OffscreenCanvas : Canvas on worker thread
OffscreenCanvas — Speed up Your Canvas Operations with a Web Worker
The text was updated successfully, but these errors were encountered: