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

[Android] Video flickering on application activate #151

Open
itlancer opened this issue Nov 18, 2019 · 2 comments
Open

[Android] Video flickering on application activate #151

itlancer opened this issue Nov 18, 2019 · 2 comments

Comments

@itlancer
Copy link

Problem Description

Activate already launched application causes video flickering.
It also happens when you return from Alarm Clock or unlock device, turn on screen or switch from another application.
It has been tested with many different AIR versions from 13.0.0.83 to latests AIR 32.0.0.144 beta and AIR 33.0.2.315 with different Android devices and Android OS versions. With armv7 and armv8 build targets. Same problem in all cases with different H.264 (MP4) videos.
Same problem in all cases. The same problem with Video and StageVideo.
It works fine with Windows, macOS and iOS.

Changing renderMode and containsVideo in application manifest doesn't help.
NetStream::useHardwareDecoder=true doesn't help - video doesn't playback at all (for AIR 33).
<disableMediaCodec>true</disableMediaCodec> doesn't help or show black rectangle instead of video when activate application.
Changing hardwareAccelerated in Android application manifest doesn't help.
Change stage quality - didn't solve it

Tracker link: https://tracker.adobe.com/#/view/AIR-3840991
Related issues (not the same):
https://tracker.adobe.com/#/view/AIR-3840983
http://forum.starling-framework.org/topic/ane-fix-for-blackblank-screen-bug-when-returning-to-air-android-apps
#87
#82
#79

Steps to Reproduce

  1. Launch code below on any Android device, it will start video playback.
  2. Deactivate application (minimize it or switch to other app or home launcher or lock device/turn off screen) when video playback.
  3. Activate application again (unlock screen/open app from Recent).
    *There could be different behavior by different ways of application deactivation/activation.

Application example with sources and example of video attached.
video_flickers_bug.zip

package {
	import flash.display.Sprite;
	import flash.net.NetConnection;
	import flash.net.NetStream;
	import flash.events.NetStatusEvent;
	import flash.media.StageVideo;
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	public class VideoFlickersBug extends Sprite {
		var nc:NetConnection;
		var ns:NetStream;
		var stageVideo:StageVideo;
		
		public function VideoFlickersBug() {
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			if (stage.stageVideos.length > 0){
				stageVideo = stage.stageVideos[0];
				stageVideo.viewPort = new Rectangle(200, 200, 640, 480);
				
				nc = new NetConnection();
				nc.addEventListener(NetStatusEvent.NET_STATUS, ncHandler);
				nc.connect(null);
			}
		}
		
		private function ncHandler(e:NetStatusEvent):void {
			if (e.info.code == "NetConnection.Connect.Success"){
				ns = new NetStream(nc);
				ns.client = {onMetaData:getMeta, onPlayStatus:onPlayStatus};
				ns.addEventListener(NetStatusEvent.NET_STATUS, nsHandler);
				
				stageVideo.attachNetStream(ns);
				ns.play("video.mp4");
			}
		}

		private function nsHandler(e:NetStatusEvent):void { trace("ns", e.info.code); }

		private function getMeta(mdata:Object):void { }

		private function onPlayStatus(infoObject:Object):void {
			if (infoObject.code == "NetStream.Play.Complete"){
				ns.seek(0);
			}
		}
	}
}

Actual Result:
Video flickers few frames. Sometimes (on some devices) it could flickers for a second with deformations.
Sometimes it could just continue to show white screen (no video) but sound of video continue playback.
Sometimes it could stop video playback (white screen).
Sometimes NetStream could dispatch NetStream.Play.Failed and stop playback.

Expected Result:
Video continue playback correctly without artifacts, deformation, flickering, stops etc.

Known Workarounds

none

@MESepehr
Copy link

Same problem. It was an old problem and has been solved, but it seems to happen again on the new generation of Androids.

@itlancer
Copy link
Author

Issue still exists with latest AIR 50.2.4.1.

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

No branches or pull requests

2 participants