Author Topic: FPS Monitor  (Read 789 times)

rand0m

  • Sr. Member
  • ****
  • Posts: 341
    • View Profile
FPS Monitor
« on: February 09, 2020, 11:31:46 PM »
Latest versions of Attract-Mode include a handy plug-in by Oomek called FPS Monitor. This monitor can be turned on through Configure > Plugin > FPS Monitor> Enabled yes. In the same page add a key for turning FPS Monitor on and off, if you have not mapped "reload" to any key then you can add a key for reload here too. I found Graph size "Large" to be best.

Usage:
When FPS Monitor is turned on in settings, it will auto-run on start (I wish default was off) go through your layout and keep an eye on the FPS Monitor, at any place where you see FPS drops (Usually between 50-59) check the layout code and see whats causing the drops. You can also narrow it down by turning off artwork one by one. Thats where reload key comes handy, after any changes in layout you can press the reload key and layout will reload with new changes.

Depending on the reason you might need to convert png to jpg or 8bit png or re-compress through website like tinyPNG (thanks Enkak!). Or you might want to resize if the image res is huge, specially when you are using reduced res output of said image in layout. You might also want to use something like Transition.EndNavigation.

BTW Videos WILL cause FPS drops, best to do this with videos disabled. I don't know of anyway to minimize drops on videos right now, though in some tests I did wmv caused minimal drops then avi them mp4. But this is on Win* system might be different on *nix. 

As Keil and Zpaolo mentioned in comments further down, multiple surfaces (specially nested) and heavy shaders can also cause slowdowns/ FPS drops, you can comment out one item at a time and reload/ check.

« Last Edit: February 10, 2020, 08:10:29 AM by rand0m »

rand0m

  • Sr. Member
  • ****
  • Posts: 341
    • View Profile
Re: FPS Monitor
« Reply #1 on: February 09, 2020, 11:32:59 PM »
Note: AM shows some drops when it first starts, in around 5-6 seconds FPS will stabilize.

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: FPS Monitor
« Reply #2 on: February 10, 2020, 05:38:31 AM »
Artwork was not a factor in the design of PICKnMIX. It was surfaces that made a difference with fps.

zpaolo11x

  • Hero Member
  • *****
  • Posts: 990
    • View Profile
    • My deviantart page
Re: FPS Monitor
« Reply #3 on: February 10, 2020, 06:17:05 AM »
Surfaces, especially nested surfaces, are the main cause of slowdowns, together with heavy glsl shaders that have an impact on low spec machines with poor GPU. But for "flowing" themes that load a lot of artwork in advance to maintain smooth scrolling, loading a 348x244 native resolution screenshot feels very different than loading high resolution box art or arcade flyers.

Avi and mpg loading causes stuttering in the same scenario (so better delay loading) and when a video is running the layout usually caps at the video framerate

rand0m

  • Sr. Member
  • ****
  • Posts: 341
    • View Profile
Re: FPS Monitor
« Reply #4 on: February 10, 2020, 08:17:51 AM »
@keilmillerjr @zpaolo11x Thanks guys, added surfaces and shaders to the list of common culprits causing slowdowns.

Surfaces, especially nested surfaces, are the main cause of slowdowns, together with heavy glsl shaders that have an impact on low spec machines with poor GPU. But for "flowing" themes that load a lot of artwork in advance to maintain smooth scrolling, loading a 348x244 native resolution screenshot feels very different than loading high resolution box art or arcade flyers.

Avi and mpg loading causes stuttering in the same scenario (so better delay loading) and when a video is running the layout usually caps at the video framerate

Thanks, about the highlighted part, I have tried some dozen ways to reduce impact of videos. i was aiming for the same thing (video delay) but no matter what I do if there are videos (playing) in a layout there are FPS drops. Most of the examples I have seen are where after x ms video becomes visible (but its playing in hidden as soon as one goes to next/ previous game, it only becomes visible after x ms).

is it possible to actually run the video after x ms (not visibility but playing)?

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: FPS Monitor
« Reply #5 on: February 10, 2020, 02:29:09 PM »
@keilmillerjr @zpaolo11x Thanks guys, added surfaces and shaders to the list of common culprits causing slowdowns.

Surfaces, especially nested surfaces, are the main cause of slowdowns, together with heavy glsl shaders that have an impact on low spec machines with poor GPU. But for "flowing" themes that load a lot of artwork in advance to maintain smooth scrolling, loading a 348x244 native resolution screenshot feels very different than loading high resolution box art or arcade flyers.

Avi and mpg loading causes stuttering in the same scenario (so better delay loading) and when a video is running the layout usually caps at the video framerate

Thanks, about the highlighted part, I have tried some dozen ways to reduce impact of videos. i was aiming for the same thing (video delay) but no matter what I do if there are videos (playing) in a layout there are FPS drops. Most of the examples I have seen are where after x ms video becomes visible (but its playing in hidden as soon as one goes to next/ previous game, it only becomes visible after x ms).

is it possible to actually run the video after x ms (not visibility but playing)?

Use tick callback to update fe.image.

rand0m

  • Sr. Member
  • ****
  • Posts: 341
    • View Profile
Re: FPS Monitor
« Reply #6 on: February 11, 2020, 01:11:55 PM »
@keilmillerjr @zpaolo11x Thanks guys, added surfaces and shaders to the list of common culprits causing slowdowns.

Surfaces, especially nested surfaces, are the main cause of slowdowns, together with heavy glsl shaders that have an impact on low spec machines with poor GPU. But for "flowing" themes that load a lot of artwork in advance to maintain smooth scrolling, loading a 348x244 native resolution screenshot feels very different than loading high resolution box art or arcade flyers.

Avi and mpg loading causes stuttering in the same scenario (so better delay loading) and when a video is running the layout usually caps at the video framerate

Thanks, about the highlighted part, I have tried some dozen ways to reduce impact of videos. i was aiming for the same thing (video delay) but no matter what I do if there are videos (playing) in a layout there are FPS drops. Most of the examples I have seen are where after x ms video becomes visible (but its playing in hidden as soon as one goes to next/ previous game, it only becomes visible after x ms).

is it possible to actually run the video after x ms (not visibility but playing)?

Use tick callback to update fe.image.

I am currently using following:
Code: [Select]
//Video Starts Playing After 1 Second In Place of Snap
local settings =
    {
        delay_timer = 0,
        play_delay = 1000,
    }

local video = fe.add_artwork("video", 680,705,472,355)
video.preserve_aspect_ratio = true;
video.mipmap = true;
video.trigger = Transition.EndNavigation;

function vid_on_transition(ttype, var, transition_time)
    {
        if (ttype == Transition.StartLayout || ttype == Transition.ToNewList || ttype == Transition.FromOldSelection)
            {
                settings.delay_timer = fe.layout.time
                video.visible = false
            }
        return false
    }

function vid_on_tick(tick_time)
    {
        if (video.video_playing && tick_time - settings.delay_timer >= settings.play_delay) video.visible = true
    }

fe.add_ticks_callback(this, "vid_on_tick")
fe.add_transition_callback(this, "vid_on_transition")

This runs the video hidden and makes it visible after a few ms. How do I adjust it so video doesn't run at previous/ next game but runs after a few ms (chnage visibility to video_playing)? Kind of stuck because I have no idea what to replace this line (  if (video.video_playing && tick_time - settings.delay_timer >= settings.play_delay) video.visible = true) with.

jclampy69

  • Full Member
  • ***
  • Posts: 74
    • View Profile
Re: FPS Monitor
« Reply #7 on: December 26, 2020, 05:49:53 PM »
@keilmillerjr @zpaolo11x Thanks guys, added surfaces and shaders to the list of common culprits causing slowdowns.

Surfaces, especially nested surfaces, are the main cause of slowdowns, together with heavy glsl shaders that have an impact on low spec machines with poor GPU. But for "flowing" themes that load a lot of artwork in advance to maintain smooth scrolling, loading a 348x244 native resolution screenshot feels very different than loading high resolution box art or arcade flyers.

Avi and mpg loading causes stuttering in the same scenario (so better delay loading) and when a video is running the layout usually caps at the video framerate

Thanks, about the highlighted part, I have tried some dozen ways to reduce impact of videos. i was aiming for the same thing (video delay) but no matter what I do if there are videos (playing) in a layout there are FPS drops. Most of the examples I have seen are where after x ms video becomes visible (but its playing in hidden as soon as one goes to next/ previous game, it only becomes visible after x ms).

is it possible to actually run the video after x ms (not visibility but playing)?

Use tick callback to update fe.image.

I am currently using following:
Code: [Select]
//Video Starts Playing After 1 Second In Place of Snap
local settings =
    {
        delay_timer = 0,
        play_delay = 1000,
    }

local video = fe.add_artwork("video", 680,705,472,355)
video.preserve_aspect_ratio = true;
video.mipmap = true;
video.trigger = Transition.EndNavigation;

function vid_on_transition(ttype, var, transition_time)
    {
        if (ttype == Transition.StartLayout || ttype == Transition.ToNewList || ttype == Transition.FromOldSelection)
            {
                settings.delay_timer = fe.layout.time
                video.visible = false
            }
        return false
    }

function vid_on_tick(tick_time)
    {
        if (video.video_playing && tick_time - settings.delay_timer >= settings.play_delay) video.visible = true
    }

fe.add_ticks_callback(this, "vid_on_tick")
fe.add_transition_callback(this, "vid_on_transition")

This runs the video hidden and makes it visible after a few ms. How do I adjust it so video doesn't run at previous/ next game but runs after a few ms (chnage visibility to video_playing)? Kind of stuck because I have no idea what to replace this line (  if (video.video_playing && tick_time - settings.delay_timer >= settings.play_delay) video.visible = true) with.
Hi, sorry for the necro, I'm not sure if rand0m still visits here. But what if you incorporated this line?
   video.video_flags = Vid.NoAutoStart;
Then change the lines in your example as follows:
video.visible = false to read video.video_playing = false
video.visible = true to read video.video_playing = true

I'm sure you already found a solution, actually I'd be interested to know what you ended up with.
« Last Edit: December 26, 2020, 06:50:58 PM by jclampy69 »

rand0m

  • Sr. Member
  • ****
  • Posts: 341
    • View Profile
Re: FPS Monitor
« Reply #8 on: December 28, 2020, 05:54:01 AM »
Hi, sorry for the necro, I'm not sure if rand0m still visits here. But what if you incorporated this line?
   video.video_flags = Vid.NoAutoStart;
Then change the lines in your example as follows:
video.visible = false to read video.video_playing = false
video.visible = true to read video.video_playing = true

I'm sure you already found a solution, actually I'd be interested to know what you ended up with.

Hi, Vid.NoAutoStart still processes the video file so the FPS drops are same. Oomek helped me out through a "fe.get_art" code, listed below is a little modified version of Oomek's code:

Code: [Select]
local settings =
{
delay_timer = 0,
play_delay = 400,
video_reload = false
}

local vid_txt = fe.add_text( "", 0,0,0,0) //debug
vid_txt.set_bg_rgb(50,50,50) //debug
vid_txt.align = Align.BottomCentre //debug
vid_txt.char_size = 1 //debug

local video = fe.add_image("video", 680,705,472,355)
video.preserve_aspect_ratio = true
video.mipmap = true
video.file_name = ""

function video_on_transition(ttype, var, transition_time)
{
if (ttype == Transition.StartLayout || ttype == Transition.ToNewList || ttype == Transition.ToNewSelection)
{
settings.delay_timer = fe.layout.time
settings.video_reload = true
video.file_name = "" // comment the line if you want the video to stay until EndNavigation
}
return false
}

function video_on_tick(tick_time)
{
if (settings.video_reload && tick_time - settings.delay_timer >= settings.play_delay)
{
vid_txt.msg = fe.get_art("video") //debug
video.file_name = fe.get_art("video")
settings.video_reload = false
}
}

Couple of pointers!
1. This code starts processing the video once you stay on game item for 400 millisec. The way I designed the theme is that video starts running on top of a gameplay snap, so snap is visible in normal browsing and video only runs when you wait for half a sec on an item.

2. FPS drops were reduced from 52-56 to 58-59m, hardly noticeable.

3. I am running AM on HDD, running AM on SSD (where media items are on same SSD) will probably have no FPS drops at all.


jclampy69

  • Full Member
  • ***
  • Posts: 74
    • View Profile
Re: FPS Monitor
« Reply #9 on: January 04, 2021, 09:24:58 PM »
Thanks for the response, I'll look over this when I get some free time. Anything to help with performance or efficient resource usage is great!  :)

Edit1:
````
I tried it, but I didn't notice any difference in performance compared to my current implementation in DynamicArcade. Using FPS Monitor I checked both FPS graph and frame-time graph. Single item scroll or infinite scrolling of the list, there just wasn't really a difference between methods. The dips and peaks were basically the same. I tested on both a small list and on a multi thousand list. Possibly my PC is just doing it too quickly to notice a difference. If I get a chance to test it on a lower spec system I will revisit this.

Edit2:
````
Actually I might end up testing this under more load soon. I'm contemplating creating an animation with two different video snaps displaying on screen at the same time.
« Last Edit: January 07, 2021, 12:57:25 AM by jclampy69 »