Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitmap glitches with AIR 26/27 #19

Closed
timoisalive opened this issue Aug 31, 2017 · 7 comments
Closed

Bitmap glitches with AIR 26/27 #19

timoisalive opened this issue Aug 31, 2017 · 7 comments

Comments

@timoisalive
Copy link

My app uses Starling and traditional display list for rendering. I switch between them depending on the app state. On traditional display list I draw into a BitmapData/Bitmap. I'm looking into updating to AIR 26 at the moment, but very soon I noticed strange glitches when drawing into the bitmap. This happens when running on iOS or Android, not on desktop. On AIR 25 and below things are also fine, only AIR 26 and 27 seem to be affected.

Here's what it looks like:

https://drive.google.com/open?id=0B-vNf0XbY6TCc2FiVDdfTXZKZ3c

I'm drawing the blue pixels, but the thin white line right below is "not supposed to happen".

When I change from Starling to traditional display list rendering, I also stop Starling. I noticed, that if I DON'T stop Starling in the background, the glitches on the bitmap do not appear! However, I'd like to stop Starling as it takes up CPU resources.

Here's a link to Adobe Tracker issue:

https://tracker.adobe.com/#/view/AIR-4198453

Here's the discussion on Starling forum:

https://forum.starling-framework.org/topic/bitmap-glitches-with-air-2627

And here's a minimal project to reproduce the issue:

package {
 
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
 
	import starling.core.Starling;
	import starling.events.Event;
 
	[SWF(frameRate="60", backgroundColor="#ffffff")]
	public class Main extends Sprite {
 
        public function Main() {
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.addEventListener(flash.events.Event.RESIZE, onStageResize);
        }
 
		private function onStageResize(event:flash.events.Event):void {
			stage.removeEventListener(flash.events.Event.RESIZE, onStageResize);
 
			function onRootCreated(event:starling.events.Event):void {
				Starling.current.removeEventListener(starling.events.Event.ROOT_CREATED, onRootCreated);
				Starling.current.start();
 
				Starling.current.stop(true);
				stage.addEventListener(flash.events.Event.ENTER_FRAME, function(event:flash.events.Event):void {
					Starling.context.present();
				});
 
				stage.addChild(new MainFlash(stage));
			}
 
			new Starling(MainStarling, stage, null, null, "auto", "auto");
			Starling.current.skipUnchangedFrames = true;
			Starling.current.supportHighResolutions = true;
			Starling.current.addEventListener(starling.events.Event.ROOT_CREATED, onRootCreated);
		}
 
    }
 
}
 
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.MouseEvent;
 
import starling.display.Sprite;
 
internal class MainFlash extends flash.display.Sprite {
 
	private var _bmpB:Bitmap;
	private var _bmpA:Bitmap;
	private var _bmpDataB:BitmapData;
	private var _bmpDataA:BitmapData;
	private var _drawButton:flash.display.Sprite;
 
	public function MainFlash(stage:Stage) {
		var scale:Number = 8;
 
		_bmpDataA = new BitmapData(stage.stageWidth / scale, stage.stageHeight / scale, false, 0xffc0c0c0);
		_bmpA = new Bitmap(_bmpDataA);
		_bmpA.scaleX = scale;
		_bmpA.scaleY = scale;
		addChild(_bmpA);
 
		_bmpDataB = new BitmapData(stage.stageWidth / scale, stage.stageHeight / scale, true, 0x00000000);
		_bmpB = new Bitmap(_bmpDataB);
		_bmpB.scaleX = scale;
		_bmpB.scaleY = scale;
		addChild(_bmpB);
 
		_drawButton = new flash.display.Sprite();
		_drawButton.addEventListener(MouseEvent.MOUSE_DOWN, onDrawButtonMouseEvent);
		_drawButton.addEventListener(MouseEvent.MOUSE_UP, onDrawButtonMouseEvent);
		_drawButton.graphics.beginFill(0x0000ff, 1);
		_drawButton.graphics.drawCircle(0, 0, 100);
		_drawButton.graphics.endFill();
		_drawButton.x = stage.stageWidth / 2;
		_drawButton.y = stage.stageHeight / 2;
		addChild(_drawButton);
	}
 
	private function onDrawButtonMouseEvent(event:MouseEvent):void {
		if(event.type == MouseEvent.MOUSE_DOWN)	addEventListener(flash.events.Event.ENTER_FRAME, onEnterFrame);
		else									removeEventListener(flash.events.Event.ENTER_FRAME, onEnterFrame);
	}
 
	private function onEnterFrame(event:flash.events.Event):void {
		var x:int;
		var y:int;
		for(var i:int=0; i<30; i++) {
			x = Math.floor(_bmpDataB.width - Math.random() * _bmpDataB.width / 3);
			y = Math.floor(_bmpDataB.height - Math.random() * 10);
			_bmpDataB.setPixel32(x, y, Math.random() * 0x0000ff + 0xff000000);
		}
	}
 
}
 
internal class MainStarling extends starling.display.Sprite {}
@PrimaryFeather
Copy link
Contributor

Thanks for creating the issue here, Timo!

@PrimaryFeather
Copy link
Contributor

As someone noted in the Adobe Tracker report, this might be related to this bug.

@timoisalive
Copy link
Author

timoisalive commented Sep 5, 2017

Yes, it actually seems like it's got nothing to do with Starling. I was able to completely remove it from the test project and still reproduce the issue...

But if it's related to the other bug, it's harder to say. My issue is reproduceable only on AIR 26+, whereas the other one is AIR 24+...

@PrimaryFeather
Copy link
Contributor

Hey Timo,
Adobe says this is fixed in AIR 28 — could verify this and close the issue if that's the case? Thanks in advance!

@timoisalive
Copy link
Author

timoisalive commented Jan 3, 2018 via email

@PrimaryFeather
Copy link
Contributor

No worries, Timo! Since you provided such an excellent sample project, I could verify this myself. I could reproduce the issue with AIR 26, but no longer with AIR 28. Success!

Thanks again for the report, and thanks to Adobe for the fix!

@timoisalive
Copy link
Author

timoisalive commented Jan 5, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants