Bug 218324 - REGRESSION(r269065): [GPU Process]: Order of drawing has to be preserved when drawing a canvas to another canvas
Summary: REGRESSION(r269065): [GPU Process]: Order of drawing has to be preserved when...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-10-28 23:12 PDT by Said Abou-Hallawa
Modified: 2020-10-29 13:28 PDT (History)
5 users (show)

See Also:


Attachments
Patch (9.16 KB, patch)
2020-10-28 23:16 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2020-10-28 23:12:53 PDT
When drawing an ImageBuffer to another ImageBuffer, the DrawingContext of the source and the destination ImageBuffers have to be flushed immediately. Otherwise an older version or a newer version of the source ImageBuffer might be drawn to the destination ImageBuffer. Consider this example and assume GPU rendering is enabled for canvas.

    <script>
        var canvas1 = document.getElementById('canvas1');
        var canvas2 = document.getElementById('canvas2');
        var canvas3 = document.getElementById('canvas3');

        var ctx3 = canvas3.getContext('2d');
        ctx3.fillStyle = 'red';
        ctx3.fillRect(0, 0, 100, 100);

        var ctx1 = canvas1.getContext('2d');
        ctx1.drawImage(canvas3, 0, 0);

        ctx3.fillStyle = 'green';
        ctx3.fillRect(0, 0, 100, 100);

        var ctx2 = canvas2.getContext('2d');
        ctx2.drawImage(canvas3, 0, 0);

        ctx3.fillStyle = 'blue';
        ctx3.fillRect(0, 0, 100, 100);
    </script>

1. If we do not flush any of the canvases after the "drawImage" calls, the first two canvases will not be drawn. This means an older version of canvas3 is drawn to canvas1 and canvas2.
2. If we flush canvas3 after the "drawImage" calls, all the canvases will be filled with blue. This means a newer version of canvas3 is drawn to canvas1 and canvas2.
Comment 1 Said Abou-Hallawa 2020-10-28 23:16:43 PDT
Created attachment 412616 [details]
Patch
Comment 2 EWS 2020-10-29 11:36:03 PDT
Committed r269159: <https://trac.webkit.org/changeset/269159>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 412616 [details].
Comment 3 Radar WebKit Bug Importer 2020-10-29 11:37:17 PDT
<rdar://problem/70818638>