Highlighted

Background frame rate

New Here ,
Apr 09, 2015

Copy link to clipboard

Copied

Is there any way to change the default frame rate when the app goes in background? The default rate drops to smth like 4fps or even less when the app is in background and I need to change that to a higher number because the app takes forever to switch tracks (this is an audio streaming app). If the app has the focus, the track switching is immediate but when the frame rate drops it takes up to one minute. Any suggestions would be greatly appreciated.

Just for fyi, I understand the reasons why the frame rate is lowered. There are good articles out there that explain the reasons and best coding practices to ensure that the app does not waste device battery. In my case, I just need to be able to throttle the frame rate up when switching tracks and then back down. I can 't seem to find a way to do it. Maybe it's not possible...that is why I am reaching out to folks in this forum.

TOPICS
Performance issues

Views

346

Likes

Translate

Translate

Report

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

Background frame rate

New Here ,
Apr 09, 2015

Copy link to clipboard

Copied

Is there any way to change the default frame rate when the app goes in background? The default rate drops to smth like 4fps or even less when the app is in background and I need to change that to a higher number because the app takes forever to switch tracks (this is an audio streaming app). If the app has the focus, the track switching is immediate but when the frame rate drops it takes up to one minute. Any suggestions would be greatly appreciated.

Just for fyi, I understand the reasons why the frame rate is lowered. There are good articles out there that explain the reasons and best coding practices to ensure that the app does not waste device battery. In my case, I just need to be able to throttle the frame rate up when switching tracks and then back down. I can 't seem to find a way to do it. Maybe it's not possible...that is why I am reaching out to folks in this forum.

TOPICS
Performance issues

Views

347

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 09, 2015 0
New Here ,
Apr 09, 2015

Copy link to clipboard

Copied

Never tried it myself, and don't know if its applicable in your development environment, but have you attempted to intercept the ThrottleEvent and cancel or override it?

ThrottleEvent - Adobe ActionScript® 3 (AS3 ) API Reference

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 09, 2015 0
New Here ,
Apr 10, 2015

Copy link to clipboard

Copied

Not sure. I will have to play with it. From what I can see in the API Reference, this event can not be canceled. It would be nice to know which objects are listening to this event when it is dispatched.

I added my own event listener on the stage and can see that the target frame rate drops 10fps when audio is still streaming, but then it drops even further to 4fps when the track reaches the end. So basically, the frame rate is 4fps as the app is trying to move to the next track in the playlist. The weird thing is that the stage object report of frame rate of 24fps throughout the entire time.

On Android devices, when the app is pushed to the background, even though the target frame rate is 4fps, switching between tracks never happens. Its as though the app suspends all operations when the track is over. As soon as I bring the app to the foreground, it immediately moves to the next track.

On iOS devices, the streaming stops as soon as the app goes into background. An deactivate event is dispatched first and then a Netstreaming.Pause.notify is dispatched second.

I don't get it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 10, 2015 0
Adobe Employee ,
Apr 10, 2015

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 10, 2015 0
EastMan LATEST
New Here ,
Apr 14, 2015

Copy link to clipboard

Copied

Chris,

Sorry for the late reply. I took some time to test a little more...

Tip#2 does not seem to make any difference. The stage always reports the same frame rate of 24.

private function onThrottleEvent(e:ThrottleEvent):void

{

trace("targetFrameRate is " + e.targetFrameRate);

trace("throtle state is " + e.state);

if (stage != null)

trace("stage Frame rate is" + stage.frameRate);

}

results:

targetFrameRate is 4

throtle state is throttle

stage Frame rate is 24

To further test, I set logging to true to get a better understanding of what the OSMF  was doing since I use the framework in the Android version.

-locale en_US -define CONFIG::FLASH_14_0 true  -define CONFIG::MOCK false -define CONFIG::PLATFORM true -define CONFIG::LOGGING true -swf-version=27

I can email the logs to you privately if you want them. On Android devices, logging shows that when the app is pushed in the background, the OSMF does not move beyond the wait state. Smth inside of the OSMF  behaves differently when the app is in the background mode. Let me summarize the behavior quickly one more time.

1. App is in foreground: App switches to the next track immediately.

2. App is in foreground and screen is locked: App switches to the next track. There is a few seconds delay, but it still moves to the next track.

3. App in the background with screen locked or unlocked: App does not switch to the next track. OSMF gets stuck in wait state of Seg 1 Fragment 3.

Here are the last two lines before the app gets stuck.

Mon Apr 13 2015 05:38:49 PM.607 [DEBUG] [org.osmf.net.httpstreaming.HTTPNetStream] Processed 66901 bytes ( buffer = 11.981, bufferTime = 4, wasBufferEmptied = false )

Mon Apr 13 2015 05:38:49 PM.608 [DEBUG] [org.osmf.net.httpstreaming.HTTPNetStream] State = wait

The app will stay in this state until I bring the app to the foreground.

Here are the logs when app comes to the foreground.

targetFrameRate is 24
throtle state is resume
stage Frame rate is 24
targetFrameRate is 4
throtle state is throttle
stage Frame rate is 24
targetFrameRate is 24
throtle state is resume
stage Frame rate is 24

Mon Apr 13 2015 05:40:07 PM.386 [DEBUG] [org.osmf.net.httpstreaming.HTTPNetStream] Seek complete and time updated to: 0.039. Dispatching HTTPNetStatusEvent.NET_STATUS - Seek.Notify
Mon Apr 13 2015 05:40:07 PM.387 [DEBUG] [org.osmf.net.httpstreaming.HTTPNetStream] NetStatus event:NetStream.Seek.Notify
Mon Apr 13 2015 05:40:07 PM.388 [INFO] [org.osmf.net.NetStreamLoadTrait] NetStream.Seek.Notify
Mon Apr 13 2015 05:40:15 PM.107 [DEBUG] [org.osmf.net.httpstreaming.HTTPNetStream] State = play

On iOS devices, the app behaves the same as far as the frame rate goes but the streaming stops immediately when the app is pushed to the background or the screen  is locked. I don't use the OSMF in iOS app but I use the Netstream class in combination with StageVideo to be able to consume HLS streams. Here are some traces.

(pushed to the background)

app status is ....deactivate

stage video is available

NetStream.Play.Stop

targetFrameRate is 4

(brought to the foreground)

throttle state is throttle

stage Frame rate is 24

targetFrameRate is 24

throttle state is resume

stage Frame rate is 24

When the app dispatches the Deactivate event, it also forces the Netstream  to stop streaming. The documentation that I have read says that when the app enters background, video stops rendering but in this case I am streaming audio only so I don't see the reason why NetStream.Play.Stop is dispatched on deactivate. In app.xml, I have also the correct setting to be able to play background audio.

<key>UIBackgroundModes</key>

  <array>

  <string>audio</string>

  </array>

Any thoughts? The app is available in both Android and Apple stores so you can easily download and test the  behavior yourself.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 14, 2015 0