為了改善您的使用體驗,本網站正在進行維護,部分功能暫時無法使用。若本站的文件無法解決您的問題,想要向社群發問的話,請到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 發問,我們的社群成員將很快會回覆您的疑問。

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

Firefox skips rendering text in Canvas

  • 1 回覆
  • 2 有這個問題
  • 8 次檢視
  • 最近回覆由 cor-el

more options

Please find below jsfiddle for reference

jsFiddle for Mozilla Firefox -- http://jsfiddle.net/ranu_mandan/EBmdf/

Javascript (FF)

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="30px Arial";

var counter = 0;
c.addEventListener('DOMMouseScroll',function(event){

    draw();

    return false;

}, false);

function draw(){   

   var j = ++counter;
   for(var i = 0; i < 10000; i++){
    ctx.clearRect(0, 0, c.width, c.height);
    ctx.fillText("Hello World " + j ,10,50);
   }

 }

jsFiddle for Google Chrome -- http://jsfiddle.net/ranu_mandan/mk5rZ/

Javascript (Chrome)

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.font="30px Arial";

var counter = 0;
c.addEventListener('mousewheel',function(event){

   draw();

   return false;

}, false);

function draw(){   

  var j = ++counter;
  for(var i = 0; i < 10000; i++){
   ctx.clearRect(0, 0, c.width, c.height);
   ctx.fillText("Hello World " + j ,10,50);
  }
}

HTML

<!DOCTYPE html>
<html>
<body>
<span>Scroll on below canvas</span>
<br/>    
<canvas id="myCanvas" width="600" height="100" style="border:5px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
</body>
</html>

Now try Scrolling fast using mouseWheel on canvas on above fiddles , you will find numbers are skipped in Firefox , whereas Google Chrome renders smoothly without skipping the numbers.

How to make rendering similar to Google Chrome in Firefox browser ?

Please find below jsfiddle for reference jsFiddle for Mozilla Firefox -- http://jsfiddle.net/ranu_mandan/EBmdf/ Javascript (FF) <br /> <pre><nowiki>var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.font="30px Arial"; var counter = 0; c.addEventListener('DOMMouseScroll',function(event){ draw(); return false; }, false); function draw(){ var j = ++counter; for(var i = 0; i < 10000; i++){ ctx.clearRect(0, 0, c.width, c.height); ctx.fillText("Hello World " + j ,10,50); } } </nowiki></pre> jsFiddle for Google Chrome -- http://jsfiddle.net/ranu_mandan/mk5rZ/ Javascript (Chrome) <br /> <pre><nowiki>var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.font="30px Arial"; var counter = 0; c.addEventListener('mousewheel',function(event){ draw(); return false; }, false); function draw(){ var j = ++counter; for(var i = 0; i < 10000; i++){ ctx.clearRect(0, 0, c.width, c.height); ctx.fillText("Hello World " + j ,10,50); } } </nowiki></pre> HTML <br /> <pre><nowiki><!DOCTYPE html> <html> <body> <span>Scroll on below canvas</span> <br/> <canvas id="myCanvas" width="600" height="100" style="border:5px solid #d3d3d3;"> Your browser does not support the HTML5 canvas tag.</canvas> </body> </html></nowiki></pre> Now try Scrolling fast using mouseWheel on canvas on above fiddles , you will find numbers are skipped in Firefox , whereas Google Chrome renders smoothly without skipping the numbers. How to make rendering similar to Google Chrome in Firefox browser ?

由 cor-el 於 修改

所有回覆 (1)

more options

A good place to ask advice about web development is at the MozillaZine "Web Development/Standards Evangelism" forum.

The helpers at that forum are more knowledgeable about web development issues.
You need to register at the MozillaZine forum site in order to post at that forum.