Skip to content

Conversation

@thieman
Copy link

@thieman thieman commented May 7, 2025

As part of a general performance investigation, I found out that rendering the stats overlay was taking up to 20ms on my ATV 4K 1st Gen. This hangs the main thread long enough that the next displayLinkCallback is missed and results in skipped frames. A snapshot from a profile below shows a spike where the main thread was saturated due to activity related to updateOverlayText.

Pasted Graphic

Our goal here is to reduce the time spent drawing the stats overlay. To do this, we switch the overlay from a UITextView to a UILabel. I am a complete novice at iOS, I just tried this because the UILabel seemed like a simpler solution for rendering a simple stats overlay. However, this did seem to improve the rendering times by quite a bit. On the same device, I'm seeing updateOverlayText typically take only around 3ms now, down from 20ms. This has removed the visible frame skips that previously happened with the stats overlay is displayed.

As part of this, also took another stab at styling the overlay since the default UILabel was pretty ugly. Added a bit of margin at the top, increased opacity slightly, and increased font weight. I think the new label is much more legible but you can still see through to the content if you need to.

Screenshot of the new label

image

@@ -0,0 +1,15 @@
//
Copy link
Author

@thieman thieman May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclosure: I am a complete iOS novice, some of this PR was generated by LLM tools but I've read through everything submitted here.

@thieman thieman force-pushed the thieman/stats-overlay-uilabel branch from 6b1f9e7 to ca596fe Compare May 7, 2025 00:03
@thieman thieman force-pushed the thieman/stats-overlay-uilabel branch from ca596fe to 58c5844 Compare May 7, 2025 00:04
[_overlayView setText:text];
[_overlayView sizeToFit];
[_overlayView setCenter:CGPointMake(self.view.frame.size.width / 2, _overlayView.frame.size.height / 2)];
[_overlayView setCenter:CGPointMake(self.view.frame.size.width / 2, (12 + (_overlayView.frame.size.height / 2)))];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing having a random 12 in here is not the best idea, is there a better way I could do this?

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

Successfully merging this pull request may close these issues.

1 participant