[opt] Use UILabel for stats overlay#671
Open
thieman wants to merge 2 commits intomoonlight-stream:masterfrom
Open
[opt] Use UILabel for stats overlay#671thieman wants to merge 2 commits intomoonlight-stream:masterfrom
thieman wants to merge 2 commits intomoonlight-stream:masterfrom
Conversation
thieman
commented
May 7, 2025
| @@ -0,0 +1,15 @@ | |||
| // | |||
Author
There was a problem hiding this comment.
Disclosure: I am a complete iOS novice, some of this PR was generated by LLM tools but I've read through everything submitted here.
6b1f9e7 to
ca596fe
Compare
ca596fe to
58c5844
Compare
thieman
commented
May 7, 2025
| [_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)))]; |
Author
There was a problem hiding this comment.
I'm guessing having a random 12 in here is not the best idea, is there a better way I could do this?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.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
updateOverlayTexttypically 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