airsdk / Adobe-Runtime-Support

Report, track and discuss issues in Adobe AIR. Monitored by Adobe - and HARMAN - and maintained by the AIR community.
201 stars 11 forks source link

Input dispatching timed out ANRs & ANR rate survey #29

Open neuronix opened 6 years ago

neuronix commented 6 years ago

Hi guys,

I am mirorring my post from the Starling forum here with Daniel's permission.

We have ANRs on Android in all our apps and would like to know if it's maybe our apps particularly, or if it's AIR related.

Could you please check your Google Dev Console and go to "Android Vitals" > "Overview".

The first section is "Bad Behaviors".

Please share the following values (no need to mention the app, just pick the biggest app you have or the average of all your apps please):

The main ANR we are experiencing is "Input dispatching timed out" triggered by "com.adobe.air.customHandler.callTimeoutFunction". There are heaps of topics on it on the web, and they only proper response by Adobe is that we should avoid doing heavy calculations on user input.

But all our apps use Starling, and Starling defers all user inputs to next frame so this should not be an issue.

gsario commented 6 years ago

@Megabyteceer i think @viveknegi1 asks about test version of AIR SDK 31 that he shared. @smileygamer can you please share your ANR-s?

aram-ahak commented 6 years ago

@marchbold This link distriqt/ANE-MediaPlayer#95 is not available

smileygamer commented 6 years ago

@viveknegi1 Here are the crash logs since AIR 31: https://www.dropbox.com/s/qcl7ya0rjq9qu3g/AIR31_crash_logs.txt?dl=0

@gevorg-gsar Most of the ANR's I get with AIR 31 are related to the CoreMobile ANE (com.milkmangames.extensions.android.CMBootReceiver). Probably because I'm showing an alert too soon after startup, which is not responsive immediatly.

gsario commented 6 years ago

@smileygamer are you saying that AIR SDK 31 have reduced number of audio related ANR-s? If so, how reduced? Any idea? Also are there any other new crashes or ANR-s that you would account to AIR SDK 31?

selimcik61 commented 6 years ago

hi ! i fixed this problem.error count is zero.it is very easy.try this.

var s:Sound = new Sound(); 
var sndChannel2:SoundChannel = new SoundChannel();
var localSound:Sound;   
var req:URLRequest = new URLRequest(arraySES1[index]); 
s.load(req); 

s.addEventListener(Event.COMPLETE, onLoadComplete); 
s.addEventListener(IOErrorEvent.IO_ERROR, onIOError);   

function onLoadComplete(event:Event):void {

    localSound = event.target as Sound; 
        sndChannel2 = localSound.play();
    sndChannel2.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete4);
} 

function onPlaybackComplete4(event:Event) :void {
//....................
sestamam(); 
}

function onIOError(event:IOErrorEvent) { 

//......................    
    sestamam(); 
}   

function sestamam()  {
//................
}
OceanBreezeGames commented 6 years ago

@selimcik61

What Adobe Air SDK did you use to apply this fix? The experimental version 31?

I see your complete and error events are calling some function which does nothing, sestamam(). Is this part of the trick you figure that fixed it for you?

On Mon, Jun 11, 2018 at 3:15 PM, selimcik61 notifications@github.com wrote:

hi ! i fixed this problem.error count is zero.it is very easy.try this.

var s:Sound = new Sound(); var sndChannel2:SoundChannel = new SoundChannel(); var localSound:Sound; var req:URLRequest = new URLRequest(arraySES1[index]); s.load(req);

s.addEventListener(Event.COMPLETE, onLoadComplete); s.addEventListener(IOErrorEvent.IO_ERROR, onIOError);

function onLoadComplete(event:Event):void {

localSound = event.target as Sound; sndChannel2 = localSound.play(); sndChannel2.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete4);

}

function onPlaybackComplete4(event:Event) :void { //.................... sestamam(); }

function onIOError(event:IOErrorEvent) {

//...................... sestamam(); }

function sestamam() { //................ }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Gamua/Adobe-Runtime-Support/issues/29#issuecomment-396389638, or mute the thread https://github.com/notifications/unsubscribe-auth/ALh3aIfWLXeS2jrtW8tTggKGmGGtpqjJks5t7t3YgaJpZM4QwWh4 .

selimcik61 commented 6 years ago

I made a mistake here..previous code;

//--------------------------------------------------------------------- var s:Sound = new Sound(); var sndChannel2:SoundChannel = new SoundChannel(); var localSound:Sound;
var req:URLRequest = new URLRequest(arraySES1[index]); s.load(req);

s.addEventListener(Event.COMPLETE, onLoadComplete); s.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
sndChannel2.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete4);

localSound = event.target as Sound; 
    sndChannel2 = localSound.play(); 

function onLoadComplete(event:Event):void { //... } function onPlaybackComplete4(event:Event) :void { //...
} function onIOError(event:IOErrorEvent) { //... }

//-----------------------------latest code--------------------------------------- var s:Sound = new Sound(); var sndChannel2:SoundChannel = new SoundChannel(); var localSound:Sound;
var req:URLRequest = new URLRequest(arraySES1[index]); s.load(req);

s.addEventListener(Event.COMPLETE, onLoadComplete); s.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
sndChannel2.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete4);

function onLoadComplete(event:Event):void { localSound = event.target as Sound; sndChannel2 = localSound.play(); //(play audio after uploading files)// } function onPlaybackComplete4(event:Event) :void { //...
} function onIOError(event:IOErrorEvent) { //... }

play audio after uploading files.this was my fault.Adobe Air SDK is not important. i used AIRSDK_Compiler-29.0.0.122.

gsario commented 6 years ago

@smileygamer just posting this here again. Are you saying that AIR SDK 31 have reduced number of audio related ANR-s? If so, how reduced? Any idea? Also are there any other new crashes or ANR-s that you would account to AIR SDK 31?

smileygamer commented 6 years ago

@gevorg-gsar I have no more audio related ANR's with AIR 31, and all crashes marked as new are related to audio.

selimcik61 commented 6 years ago

i use air sdk 29.my ANR was %3. Now, i have reduce zero of audio related ANR. i think that the sdk version is not important for this problem.

I was used 2 events, s.addEventListener(IOErrorEvent.IO_ERROR, onIOError); sndChannel2.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete4);

and I got a lot of mistakes like this.

than I added this event,

s.addEventListener(Event.COMPLETE, onLoadComplete)

and I played the sound when the installation was completed.

s.addEventListener(Event.COMPLETE, onLoadComplete)

function onLoadComplete(event:Event):void {

localSound = event.target as Sound;

sndChannel2 = localSound.play();

}

now , i haven't any other new crashes or ANR-s to AIR SDK 29. zero ANR .sorry for my english languege.


Gönderen: Gevorg Sargsyan notifications@github.com Gönderildi: 12 Haziran 2018 Salı 14:31 Kime: Gamua/Adobe-Runtime-Support Bilgi: selimcik61; Mention Konu: Re: [Gamua/Adobe-Runtime-Support] Input dispatching timed out ANRs & ANR rate survey (#29)

@smileygamerhttps://github.com/smileygamer just posting this here again. Are you saying that AIR SDK 31 have reduced number of audio related ANR-s? If so, how reduced? Any idea? Also are there any other new crashes or ANR-s that you would account to AIR SDK 31?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Gamua/Adobe-Runtime-Support/issues/29#issuecomment-396557620, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AmUonBYh3QxxKQjr0Ry8s_dUW-tMA5z-ks5t76acgaJpZM4QwWh4.

gsario commented 6 years ago

@smileygamer thank you so much for answering! Good news that there are no ANR-s! But how many new crashes did you get? Just a few? Many? We want to understand if AIR SDK 31 will improve our app.

selimcik61 commented 6 years ago

ekran alintisi

selimcik61 commented 6 years ago

last 60 days

selimcik61 commented 6 years ago

AIR SDK 31 is beta version. you must use 30.

neuronix commented 6 years ago

I'm a bit skeptical, I don't see how this would fix issues related to playing sounds when we already have loaded them. Also, the app in question does not have a very big install base so ANR % is not statistically reliable.

@viveknegi1 do you have any feedback on the crashes @smileygamer now sees in his logs?

smileygamer commented 6 years ago

@gevorg-gsar 425 new crashes for 1877 installs of the phased update, in about 4-5 days. So the crash % would be well above the threshold for this version. AIR 31 in itself is clearly not the solution, we need a fix for the audio issue.

MAC-Joyco commented 6 years ago

@selimcik61 I think your "latest code" has some bugs, since the SoundChannel object that you create at the beginning is overwritten by the one returned by localSound.play (), so the event Event.SOUND_COMPLETE that you add to the first object should not have any effect. On the other hand, if the solution is to reload each sound before playing it, it does not seem like an efficient solution for arcade games.

selimcik61 commented 6 years ago

function onLoadComplete(event:Event):void { localSound = event.target as Sound; sndChannel2 = localSound.play(); //(play audio after uploading files)// sndChannel2.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete4); } sorry..this is right code.

i have a few apk and sent data only for one apk data..As a result, I corrected the sound mistakes..I hope it will be useful for you.

gsario commented 6 years ago

@viveknegi1 we all would appreciate if you guys could focus on this issue!
@smileygamer's crash data is quite significant, but if anyone else tried and have crashlogs - please share!

httpwebmedia commented 6 years ago

Hello, I've been following this thread for a while and I finally decided to post some crashlogs from Google Play Android Vitals.

1- Adobe Air version 29.0.0.122 Android 6.0 (280 reports in last 7 days ....) Group of error : Broadcast of Intent { act=android.intent.action.SCREEN_OFF flg=0x50000010 } Report here: https://pastebin.com/57CrdMHU

2- Adobe Air version 29.0.0.122 Android 7.1 (198 reports in last 7 days ....) Group of error : Input dispatching timed out (Waiting to send key event because the focused window has not finished processing all of the input events that were previously delivered to it. Outbound queue length: 0. Wait queue length: 2.) Report here: https://pastebin.com/ENZsnrrd

3- Adobe Air version 29.0.0.122 Android 4.4 (140 reports in last 7 days ....) Group of error : Broadcast of Intent { act=android.intent.action.SCREEN_ON flg=0x50000010 } Report here: https://pastebin.com/cQtTnjzs

Apart the fact that most of the errors are now related to audio tracks since adobe air 22 we have many reports that starts with "Input dispatching timed out"

Adobe should has to put their efforts on resolving these majors issues instead of adding new features. Google's main focus is getting end-users happy It's no coincidence that they provided such a tool : to keep end-users happy.

gsario commented 6 years ago

@httpwebmedia great stuff! But I think what @viveknegi1 needs is crash logs from apps using AIR SDK 31 that he shared here. So if you can upload a build of your app with new SDK and then share crash log, that would be great. We are working on the same right now!

smileygamer commented 6 years ago

@selimcik61 We did an experiment with your solution, but we still get the audio related ANR's. Contrary to what you did, we reused the sounds once loaded. So if the solution is the reloading of sounds before playing (as @MAC-Joyco said), that doesn't seem like a good idea.

denmorgenshtern commented 6 years ago

But are there any solution for streaming sounds? Playback (video+audio) via NetStream causing ANRs too. Make all playback native - is a our bigger task for future, but any ways to extract sounds from stream and redirect it to some ANE?

gsario commented 6 years ago

@denmorgenshtern playing sounds only through ANE seems to fox ANR-s. But the thing is that there are 2 ANE-s in the market now allowing this. AACPlayer from FreshPlanet and MediaPlayer from Distriqt. Both didn't work well for us.

  1. Both had issues with sounds interrupting abruptly.
  2. Looping sounds doesn't work smoothly, gap between loop can be listened.
  3. MediaPlayer have issues with playing several instances of the same sound at the same time.
selimcik61 commented 6 years ago

@smileygamer https://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d25.html yet I do not have any ANR .i used AIR SDK 29. Now I updating to 30..I will report the result.

pnico commented 6 years ago

Just a note that we've also seen the audio-related ANRs disappear after moving all audio playback to an ANE. We added a rudimentary way to access SoundPool to our ANE for short sounds because we found that some sounds were cut off at the end on some Samsung devices, due to some Samsung bug according to the exoplayer developers.

gsario commented 6 years ago

@pnico that's great, thanks for sharing! Can you please describe how you did access SoundPool? We are having a bit of hard time getting sounds to work properly regarding multiple short sounds playback and music looping through ANE-s. Some shared info would be appreciated a lot!

httpwebmedia commented 6 years ago

Ok here is what we did with Adobe Air 31 for android.

We first removed every native extensions and we removed the sounds in the game. You'll notice that we get not much errors.

air-31-with-no-sound-and-no-ane

And then, we added the sounds and see what happens now!

dcf2234587bc10f76ace209bbe2a6cfd1b8b48a908d539a162 pimgpsh_thumbnail_win_distr air-31-with-sounds-and-no-ane-1

@viveknegi1 : We are here to help fixing that issue. You can contact me if you need more details.

The 31 version is clearly not the solution :(

gsario commented 6 years ago

@viveknegi1 we are joining to the pledge! Please get this fixed! @httpwebmedia we are 100% with you on this, this issue need urgent fix from Adobe!

neuronix commented 6 years ago

I'd also like to thank @smileygamer and @httpwebmedia for testing the AIR SDK 31 and sharing the results. Not only for the time it takes but for sacrificing some users who got ANRs & Crashes during the test rollout.

@viveknegi1 please fix :)

pnico commented 6 years ago

@gevorg-gsar, we don't need seamlessly looping sounds, and when we use exoplayer we play the sound once and then dispose the sound player so we don't have the issues you ran into. For us, SoundPool for short sounds and exoplayer for longer ones (played once, no looping) seems to work well enough. We've run into issues with having too many instances of exoplayer active at the same time, problems start to occur around 9 or 10 at once but it's not exact.

viveknegi1 commented 6 years ago

Thanks for sharing all this information. We are looking into it.

denmorgenshtern commented 6 years ago

@viveknegi1 maybe there's a way around it? Do not use soundTransform for volume control or something? We need some quick fix or workaround ASAP! Google already send us a letter about high anr rates!

rewb0rn commented 6 years ago

A workaround that we are using for a couple of years already is to endlessly loop a sound with volume 0 in the background all the time. This is preventing ANRs for our apps. In the Android Logs I was seeing the ANRs being related to sound channels being closed. Looping a single sound prevents the sound channels from closing, thus preventing the ANR. I hope it helps.

httpwebmedia commented 6 years ago

@rewb0rn Code example?

denmorgenshtern commented 6 years ago

@rewb0rn wow, great! Is this any sound with volume set to 0 via SoundTransform or is it "recorded silence"?

mspdevelopers commented 6 years ago

I just tested it and it seems that the workaround works. I used logcat to see the console. I was getting a lot of buffer exceptions after closing all sound channels, but now they are gone. I will make a new release soon with this workaround and I will put my results here.

neuronix commented 6 years ago

@rewb0rn Wow, this is really awesome news! @viveknegi1 I guess this should also be good insight for the future fix.

rewb0rn commented 6 years ago

Yes this is just any sound with a volume of 0. Happy to see this is solving the problem for you. I would have shared it earlier but you all seemed so happy with the ANE that I thought you were good :)

For reference, this my original report of the issue in the forums 5 years ago, but I think I was not the only one. https://forums.adobe.com/message/5060502#5060502

There is also a tracker issue here: https://tracker.adobe.com/#/view/AIR-3627793

PS: Now that I read my own comment there, the workaround has the problem of causing wakelocks. To fix this, you can instantiate a timer of say 10 minutes to close the application after the app has been minimized. Otherwise the workaround will prevent the app from going to full sleep, which Google will track as a problem.

gsario commented 6 years ago

@rewb0rn where have been all this time?! :)) So you are just playing a sound endlessly via loop parameter set to very high number? _sound.play(0, 9999999, new SoundTransform(0));

Another question: will closing a deactivated app on timer work?

@viveknegi1 indeed a great insight for your to get to the reason and come up with a solution!

viveknegi1 commented 6 years ago

Thanks again @rewb0rn and others. We are looking into this. I'll update this thread when we have more information on this.

MAC-Joyco commented 6 years ago

@rewb0rn Thanks for the trick! I'm thinking that a simpler solution could be to use the Sound.play loop counter itself as a timer. While the game is in the foreground, the loop is infinite, when it go to background, the sound is played with a loop number equivalent to 10 minutes, and when back from background, it becomes infinite again.

gsario commented 6 years ago

@rewb0rn we just tried and the app doesn't cause a wakelock on Android when a sound is constantly played in a loop. We also tried to execute code (quitting the app) in deactivated state based on timer and that just doesn't work. My assumption is the whole AIR app thread is paused when deactivated on Android. Ideas or thoughts on this?

@MAC-Joyco your approach will not work probably for few reasons:

  1. look at our test described above - probably no need to worry about looped sound for wakelocks.
  2. if the app is executing in deactivated state, then changing loop count to be equal to the time of 10 minutes will not help. In 10 mins your sound will stop and it will cause the same issues as before. The key is as i understand to never have situation with all sounds channels stopping when the app is running, as that is causing ANR-s.
rewb0rn commented 6 years ago

@gevorg-gsar Sorry to share our workaround so late. But I have been observing the thread and keeping an eye on the progress. My impression was that there were some workarounds with the ANEs that worked for you and I did not want to spread confusion. Yes the code you shared to repeat the sound should be fine. For us we need to quit the app when it is deactivated, but this can depend on your app permissions. Maybe if you do not prevent device sleep this is not neccessary. I have only verified our own specific use case so I don't know.

@MAC-Joyco IIRC this will not work and cause ANRs when the sound loop stops, but it's too long ago so I don't remember the details.

MAC-Joyco commented 6 years ago

@gevorg-gsar So, playing a continuous sound does not cause anrs or wakelocks? Then, Why Rewb0rn commented about wakelock issue? It would be good to confirm this point.

On the other hand, I was thinking that if the sound stops in the background it is not cause of anr, and in the worst case it would suppose a drastic reduction of the number of anr. But if it is confirmed that there are no problems of wakelocks then it is not necessary as you said.

denmorgenshtern commented 6 years ago

@gevorg-gsar Did you set NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE ? Sounds continue playing in background. Exit by timeout works.

gsario commented 6 years ago

@denmorgenshtern no we don't have KEEP_AWAKE set. We just tested it, timeout doesn't execute when app is deactivated, neither app exit command, nor anything else. Are you sure that you are able to execute code in deactivated app? Please tell us more...

neuronix commented 6 years ago

@gevorg-gsar AFAIK when the app deactivates you have a single execution "thread" allowed that starts in the deactivate event handler. So timeouts, promises or anything asynchronous will not work. You'll need to stop the repeating sound immediately on deactivate and resume on activate.

gsario commented 6 years ago

@neuronix sorry, I didn't catch what you mean in the last sentence. I think the idea is about not stopping the zero-volume sound ever. Why do you think we have to stop it on deactivate?

From wakelocks perspective - the zero-volume sound doesn't cause wakelock on Android on deactivate, anyway on our device it doesn't .

denmorgenshtern commented 6 years ago

@gevorg-gsar with SystemIdleMode.KEEP_AWAKE code executes in background, sounds plays, timers runs and app closes :)

NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, onDeactivate);

private function onDeactivate(e:Event=null):void {
    clearTimeout(exitTimeout);
    exitTimeout = setTimeout(exitApp, EXIT_DELAY);
}

private function exitApp(e:Event=null):void {     
    NativeApplication.nativeApplication.exit(408);
}

You can set NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.NORMAL on deactivate and stop looped sounds - then Android will decide when close app.