I’m not quite sure where I report this one (mainly since I’ve made no effort to find out). Though Alex Harui was (I believe) going to file a report after I posted this to flexCoders.
Since some bitmap filter functions were made multi core aware and capable, I’ve been suffering the occasional line across the results of one the convolution filters that I’ve been using for edge detection of a colour in an image.
Reading Tinic Uro’s post here : http://www.kaourantin.net/2007/06/multi-core-support.html, it would seem that some bitmap operations are now split into two, and the results joined when both threads complete.
It would appear that there’s a edge case error in the flash player code to do with this.
The flex code below is a simple test case, for me it normally displays a horizontal line where there should be none with the first couple of dozen tries, but only on a multi core machine (windows, I don’t have a recent mac to test on
)
It’s possible to set DisableMulticoreRenderer=1 in mm.cfg locally for ones flash player, unfortunately that’s not really an option for our clients.
Never mind, We are not releasing yet, it’s not a show stopper, and I’m sure it will get fixed in flash player in the future.
Download test case mxml here : Test case for multicore filter bug
See the test in action here : http://www.ifeedme.com/blog/customContent/filterbugexample/
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute” width=”400″ height=”440″ creationComplete=”init()”>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.UIComponent;
private var _bmpData:BitmapData;
private var _bmp:Bitmap;
private function init():void
{
_bmpData = getTestBitmapData();
_bmp = new Bitmap(_bmpData,"auto",true);
var ui:UIComponent = new UIComponent();
ui.addChild(_bmp);
this.addChild(ui);
}
private function getTestBitmapData():BitmapData
{
var bmpData:BitmapData = new BitmapData(400,400);
bmpData.fillRect(new Rectangle(30,30,340,340),0xFFFF0000);
return bmpData;
}
private function testFilter(bmpData:BitmapData):BitmapData
{
var matrixX:int = 3;
var matrixY:int = 3;
var o8:Number = 1.0/8.0; //one eighth
var matrix:Array = new Array
(-o8, -o8, -o8,
-o8, 1, -o8,
-o8, -o8, -o8);
var col:uint = 0xFF00FF00;
var edgeFilter:ConvolutionFilter = new ConvolutionFilter(matrixX,matrixY,matrix,1.0,0.0,true,true,col,0xFF);
bmpData.applyFilter(bmpData,bmpData.rect,new Point(0,0),edgeFilter);
return bmpData;
}
private function test():void
{
if (! demonstrated)
{
_bmp.bitmapData = testFilter(getTestBitmapData());
var i:int = 190;
for(i=198;i<202;i++)
{
if (_bmp.bitmapData.getPixel32(40,i) != 4278190080)
{
demonstrated = true;
mx.controls.Alert.show("DOH!
multicore bug found ??? \n See horizontal line artifact at \n Y = " + i);
}
}
}
}
]]>
</mx:Script>
<mx:Boolean id=”demonstrated”></mx:Boolean>
<mx:Button x=”5″ y=”405″ label=”TestFilter” click=”test()” enabled=”{!demonstrated}”/>
<mx:Button x=”85″ y=”405″ label=”Clear” click=”{demonstrated = false}”/>
</mx:Application>