Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

App going in to sleep mode ??

Engaged ,
Apr 12, 2012 Apr 12, 2012

So I've notice... when I fire up my app .. everything is butter. Everything runs smoothly.   If I don't touch the screen for a few minutes.. then touch the screen.  Everything is sluggish for 2 seconds and then back to normal.

Is this some sort of process thats putting my app to sleep or something ?

How can I get around this ?

Its not a good experience when you stop touching the app for a minute or so and then it is sluggish when you resume touching.

TOPICS
Development
7.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 13, 2012 Apr 13, 2012

Does anyone know if this is an iOS level issue ?  or AIR ?   Its so frustrating that the users experience is tainted when they don't touch the app for 2 minutes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 13, 2012 Apr 13, 2012

I just accidentally found a fix.

I was running a SWFProfiler to test my MEM usage... and noticed tha while the profiler is running ...  My app stays alive and perfect the entire time the profiler is running.

My framerate never drops below 60fps  ...

So now my question is ...    What could I put in my app that is lightweight that can keep my app active ?  Whats this profiler doing that is keeping everything running smooth and preventing the app from sleeping. ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 15, 2012 Apr 15, 2012

Ok .. this is driving me absolutely crazy! ..  

I've tried using a simple EnterFrame script to replace this Profiler .. thinking maybe that would stop this behaviour from happening.  No dice.

What is it about the profiler that is making my app run amazingly fast at all times ?

The one thing I hate about AIR is how it handles memory... and the tools for monitoring it.

Can anyone see any issues if I just leave this profiler in my app ( hidden ) and running ?   Not an ideal thing to do ...   but its keeping my app running without sluggish behaviour.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 15, 2012 Apr 15, 2012

I have tried it, but does this work?

NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/SystemIdleMode.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 15, 2012 Apr 15, 2012

Going to try this right now.

I dont think this is the problem though.  It goes into this sluggish mode after not touching it for about 10 seconds. 

I think the real problem here is that AIR is trying to be smart .. but its being dumb.

I think its trying to do some memory management or something when the app is not being interacted with..  but then when you try to interact with it.. it takes a second to get back to normal.

I'll post the results of SystemIdleMode in a few minutes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 15, 2012 Apr 15, 2012

I can confirm that this didn't do anything at all.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 29, 2012 May 29, 2012

Hi Applauz, I'm getting the exact same problem. Did you ever find a solution?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 30, 2012 May 30, 2012

Well ..   I've been trouble shooting this for like a month.

I am using this small profiler script. ...  and when this profiler is running ..  my app runs perfectly.   I set the depth to 0 so its hidden and its all good.  It's not ideal .. but its working! ..

I even ran an additional profiler ( Monster Debugger ) to monitor my framerate, cpu usage, etc... and running this small profiler isn't putting any weight on my app so I'm just leaving it in for now in hopes that AIR 3.3 final build or 3.4 fixes this issue.

I can send you the files I am using if you want to try it out.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 30, 2012 May 30, 2012

I've noticed it only happens when compiling in GPU mode, so possibly it's something to do with the way data is sent and stored to the graphics memory but really, who knows. Without GPU mode the playback isn't as smooth  and the overall feel is less polished so I want to try and stick with it. Would appreciate seeing how you implemented the profiler, sounds like the best sort of solution available right now...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 31, 2012 May 31, 2012

Yes.. you are correct that it only happens in GPU mode. 

So...  implement this to your project.

http://mrdoob.googlecode.com/svn/trunk/libs/net/hires/debug/Stats.as

Then all I have in my imports are

import net.hires.debug.Stats;

import flash.net.LocalConnection;

// Add profiler but set to bottom layer so its not seen.

addChildAt( new Stats(),0 );

I know it makes no sense.. but this fixes that issue and makes my app run super fast at all times.

Please let me know if this works for you so that I know for sure that this is what solved the problem...  its been on my mind for a while now. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 31, 2012 May 31, 2012

Thanks for the link Applauz - I can confirm it works! Also, for it to work best it needs to be placed within the visible stage area. I tried to place it off screen but this wasn't as effective.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 31, 2012 May 31, 2012

Thaks for this post Applauz, I had this issue and tried the KeepSystemAwake thing which did nothing so Ill try this method on the next update.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 01, 2012 Jun 01, 2012

Are people talking about Android or iOS? If you're talking about Android devices going to sleep, you need to include the following permisisons in order for the SystemIdleMode to work.

<uses-permission android:name="android.permission.WAKE_LOCK"/>

<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>

If this is for iOS, make sure the setting is applied within the constructor function of the main app .as file:

NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;

You can change this at anytime by setting the SystemIdleMode back to SystemIdleMode.NORMAL;

You shouldn't have to do anything else besides this to keep the device from going to sleep. I've had no trouble keeping my device(s) awake using just this method. If it's not working, then log a bug about it --> bugbase.adobe.com

iBrent

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 08, 2012 Jun 08, 2012

Brent I did what you suggested and no luck. It keeps the device from going to sleep but like Applauz was saying after 10 seconds or so the app seems to be not paying attention so on the initial touch it lags and sometimes doesnt execute bits of code it seems because my tweens turn out differently if the app is being actively used or if the same tween is executed after the 10 second wait period.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 10, 2013 Jun 10, 2013

Has anyone found out what's causing this behaviour? I've found event listeners going to sleep every once in a while too.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 25, 2013 Sep 25, 2013

This is very frustrating. Every app I've built has this problem.

I'm still using the dirty fix for this however I'm not happy about the small amount of memory being allocated to the dirty fix.

Does anyone know why this happens on iOS ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 30, 2013 Sep 30, 2013

I really wish someone from Adobe would address this.

I submitted this bug over a year ago.

I'm forced to use a hack to stop this from happening... however the compromise is that I have a constant running process in my apps that eats away at some of my CPU usage.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 12, 2013 Nov 12, 2013
LATEST

@Applauz78 - Can you post a link to the bug so we can vote? I'm seeing this consistently after 5 seconds of non-interaction with the App.

It seems that drawing anything with the Graphics API will stop this behavior, so this little snippet seems to fix the issue:

setInterval(function(sprite:Sprite){     if(!sprite.parent){  addChild(sprite); }     sprite.graphics.beginFill(0x0, 0);     sprite.graphics.drawRect(0, 0, 2, 2); }, 1000, new Sprite());

Once a second, it draws a 2px rectangle with the Graphics API.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 03, 2012 Jun 03, 2012

Awesome! ...  It's pretty crazy huh.   Someone should investigate what it is in that profiler script that solves this problem so we can just put whatever it is in to a function of its own in our applications.

For me this is only an issue on iOS.  The issue isn't present on Android or PlayBook for me.

The SystemIdleMode does absolutely nothing for me on iOS.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines