Closed Bug 1828137 Opened 2 years ago Closed 2 years ago

Canvas clearRect doesn't work with large values for width/height

Categories

(Core :: Graphics: Canvas2D, defect)

Firefox 112
x86_64
Linux
defect

Tracking

()

RESOLVED FIXED
114 Branch
Tracking Status
firefox-esr102 --- unaffected
firefox112 --- wontfix
firefox113 --- wontfix
firefox114 --- fixed

People

(Reporter: simonalling, Assigned: lsalzman)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/112.0

Steps to reproduce:

https://jsfiddle.net/Alling/ehbjc4mo/15/

All my troubleshooting was done on my ThinkPad X1 Carbon 5th Gen with Ubuntu 20.04.1.

A friend of mine did not encounter this problem in Firefox 111 on Windows 11 (IIRC).

const context = document.querySelector("canvas").getContext("2d");
context.fillStyle = "red";
context.fillRect(0, 0, 300, 300);

const actions = [
clearing(100, 100),
clearing(Math.floor(Number.MAX_SAFE_INTEGER / 10000000), Number.MAX_SAFE_INTEGER),
clearing(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER),
clearing(1000, 1000),
];

actions.forEach((action, index) => {
setTimeout(action, (index + 1) * 1000);
});

function clearing(width, height) {
return () => {
document.body.appendChild(document.createElement("br"));
document.body.appendChild(document.createTextNode("Clearing " + width + " × " + height));
context.clearRect(0, 0, width, height);
};
}

Actual results:

Firefox 109

  1. 100 × 100 rectangle cleared – ✅ expected
  2. Entire canvas cleared – ✅ expected
  3. Entire canvas cleared (idempotently) – ✅ expected
  4. Entire canvas cleared (idempotently) – ✅ expected

Firefox 110–111

  1. 100 × 100 rectangle cleared – ✅ expected
  2. Weird stripes cleared – ❌ unexpected
  3. Nothing cleared – ❌ unexpected
  4. Entire canvas cleared – ✅ expected

Firefox 112

  1. 100 × 100 rectangle cleared – ✅ expected
  2. Weird stripes cleared – ❌ unexpected
  3. Nothing cleared – ❌ unexpected
  4. Nothing cleared – ❌ unexpected

Expected results:

  1. 100 × 100 rectangle cleared
  2. Entire canvas cleared
  3. Entire canvas cleared (idempotently)
  4. Entire canvas cleared (idempotently)
OS: Unspecified → Linux
Hardware: Unspecified → x86_64

The Bugbug bot thinks this bug should belong to the 'Core::Graphics: Canvas2D' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Graphics: Canvas2D
Product: Firefox → Core

You should be able to use https://mozilla.github.io/mozregression/ to find more precise regression ranges.

Flags: needinfo?(simonalling)

(In reply to Robert Longson [:longsonr] from comment #2)

You should be able to use https://mozilla.github.io/mozregression/ to find more precise regression ranges.

Wow, what an amazing tool! I had no idea it existed, but it makes so much sense that it does, of course.

 8:31.20 INFO: Running autoland build built on 2022-09-08 19:52:05.944000, revision 490f5f14
 8:46.18 INFO: Launching /tmp/tmpk31xt7i2/firefox/firefox
 8:46.18 INFO: Application command: /tmp/tmpk31xt7i2/firefox/firefox -profile /tmp/tmp89co4lrr.mozrunner
 8:46.19 INFO: application_buildid: 20220906051025
 8:46.19 INFO: application_changeset: 490f5f14eda710bdb43b7cd839e1967da6d434d9
 8:46.19 INFO: application_name: Firefox
 8:46.19 INFO: application_repository: https://hg.mozilla.org/integration/autoland
 8:46.19 INFO: application_version: 106.0a1
Was this integration build good, bad, or broken? (type 'good', 'bad', 'skip', 'retry', 'back' or 'exit' and press Enter): bad
 9:21.71 INFO: Narrowed integration regression window from [f8e8c960, ae28cb70] (3 builds) to [f8e8c960, 490f5f14] (2 builds) (~1 steps left)
 9:21.71 INFO: No more integration revisions, bisection finished.
 9:21.71 INFO: Last good revision: f8e8c96064386b2f3405adefc512f7fbc2808ff8
 9:21.71 INFO: First bad revision: 490f5f14eda710bdb43b7cd839e1967da6d434d9
 9:21.71 INFO: Pushlog:
https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=f8e8c96064386b2f3405adefc512f7fbc2808ff8&tochange=490f5f14eda710bdb43b7cd839e1967da6d434d9

So it turns out that, based on my bisection, the regression was introduced much earlier than Firefox 110 as I wrote in the bug report, but I still cannot reproduce the issue in Firefox 109.0.

I have zero experience with Mercurial and very limited C++ knowledge, so I think this is all I can contribute at the moment.

Flags: needinfo?(simonalling)
Keywords: regression
Regressed by: 1773280
Flags: needinfo?(lsalzman)

I cannot reproduce this issue at all on my main PC with an RTX 2060 Super and Ubuntu 20.04.4, regardless of Firefox version.

Assignee: nobody → lsalzman
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Set release status flags based on info from the regressing bug 1773280

Wow, a bug fix already?! Way to go, lsalzman! Were you able to reproduce the issue?

I have not been able to reproduce it in Windows 10 on the same laptop. (I have only tried with Firefox 109 and 112.)

Pushed by lsalzman@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/78b546a4966a Support accelerating large clearRects if they encompass entire viewport. r=aosmond
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 114 Branch
Flags: needinfo?(lsalzman)

The patch landed in nightly and beta is affected.
:lsalzman, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox113 to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(lsalzman)
Flags: needinfo?(lsalzman)
Regressions: 1911231
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: