meltingice / CamanJS

Javascript HTML5 (Ca)nvas (Man)ipulation
http://camanjs.com
BSD 3-Clause "New" or "Revised" License
3.55k stars 404 forks source link

Fix the filters under Opera, fix #8 #29

Closed yannickcr closed 12 years ago

yannickcr commented 12 years ago

Hello,

After a few hours of investigation, I found that the problem seems to come from the Calculate.bezier method.

It works fine during the first call and fail on the second.

You can try :

Caman("home-example-original.jpg", "#example-canvas", function () {
  this.exposure(15)           // First call of Calculate.bezier (pass)
      .exposure(15).render(); // Second call of Calculate.bezier (fail)
});

Demo available here: http://jsfiddle.net/Country/f9pZQ/

Since it works if the developer tools of Opera are activated (JIT off) I just logged the variables in textareas for debugging.

If you use Opera you can see there is an error during the calculation of Ax during the second call.

This is very weird since the variables used for the calculation seems ok, it looks like a signed/unsigned number problem. By why only during the second call ? And why does it works if the JIT is off ? I don't know.

Even so I was able to resolve the bug using parseInt() on the result of the Cx calculation. (Another solution is to set Ax to null just before the calculation).

Here's a demo of the fixed build: http://jsfiddle.net/Country/gZYAh/

meltingice commented 12 years ago

Fantastic detective work! I've heard before that the bug lies within the Opera JIT itself, but I never had the time to actually track down where it was messing up. Thanks!