Jump to content

Just a tip for people using Linux and Firefox and experiencing slow getImageData


James Cat
 Share

Recommended Posts

Recently I struggled for a couple of days with terrible performance when using getImageData - I am using Ubuntu with Firefox 23.

after some googling I found that going to 'about:config' (in your address bar)

find gfx.xrender.enabled and set to false, then restart the browser.

After this instead of taking 2 minutes (yes 2 minutes!) to run the getImageData it took 4 seconds.

more info here:

https://bugzilla.mozilla.org/show_bug.cgi?id=550845&hide_resolved=1

Link to comment
Share on other sites

That's good to know! Though its still a problem if things are slow by default for people. My game Heat Sink had this issue. I used a canvas buffer to store pixel data for collision (since I didn't want to do collision with the several thousand dust particles that accumulate during the game), another canvas buffer for picking, and another canvas buffer for a visual effect where the motherboard gets dusty over time.

 

I was getting panned on Kongregate and Newgrounds for my game being slow though in my own testing it was running fine - until I tried it on Firefox. So its almost better to test things without this fix in place to make sure that people who don't know about this aren't going to just move past because its taking 2 minutes for them instead of 4 seconds. I hope this particular fix propagates and becomes standard in the browser quickly for that reason.

 

Edit: If this is a Linux-only bug, then I doubt it was responsible for many of the players having trouble. Anyone know if this affects IE as well?

Link to comment
Share on other sites

  • 2 weeks later...

The latest bug to watch for on this subject is this one. It's the only one I found in 2013.

Not sure where this bug is going, but at least someone at Mozilla wants to fix it.

 

In the meantime, we can usually find other techniques. Instead of getting pixel data for checking values, we can have an independent typed array. And instead of doing the get/putImageData dance, doing everything through drawing in background canvases, and painting those on the main canvas through drawImage(canvas, …).

 

That worked for me on an RTS I'm working on, that's currently in alpha.

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

In the meantime, we can usually find other techniques. Instead of getting pixel data for checking values, we can have an independent typed array. And instead of doing the get/putImageData dance, doing everything through drawing in background canvases, and painting those on the main canvas through drawImage(canvas, …).

 

 

Hi, sorry for the delayed reply! (like 3 months!) - I'm using independent typed arrays but initialising/filling my typedarrays with a getImageData after loading the image from the server, it only happens once but I still need to do it. how are you doing it ? I tried doing a binary load of a PNG but I just got the compressed data, and didn't know what to do next ... :-) ??

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...