@@ 173,24 173,30 @@ func (u *UI) Run() error {
// we return to end the event loop.
return ev.Err
case system.FrameEvent:
- // If we get a frame event, it's time to display a new frame. First, we
- // build a layout context using our operation list and info from the frame
- // event.
- gtx := layout.NewContext(&ops, ev)
- // Install some global key event handlers for some dev hotkeys.
- u.hotkeys(gtx)
- // Then we lay out our UI to generate an operation list.
- u.page.Layout(gtx)
- // Then we give the operation list to Gio. This actually triggers rendering
- // our window.
- ev.Frame(gtx.Ops)
- // Trigger a sweep of our stream controller. Doing this once per frame allows
- // us to gracefully start and stop UI-driven streams of data from our backend
- // without manually managing their lifecycle. If we sweep twice and a given stream
- // was not used between them, we can conclude that it is not powering an active
- // portion of the UI and shut it down for now.
- // All that you really need to remember is that this must be called once per frame.
- u.controller.Sweep()
+ trace.WithRegion(u.parentCtx, "frame", func() {
+ // If we get a frame event, it's time to display a new frame. First, we
+ // build a layout context using our operation list and info from the frame
+ // event.
+ gtx := layout.NewContext(&ops, ev)
+ trace.WithRegion(u.parentCtx, "layout", func() {
+ // Install some global key event handlers for some dev hotkeys.
+ u.hotkeys(gtx)
+ // Then we lay out our UI to generate an operation list.
+ u.page.Layout(gtx)
+ })
+ trace.WithRegion(u.parentCtx, "render", func() {
+ // Then we give the operation list to Gio. This actually triggers rendering
+ // our window.
+ ev.Frame(gtx.Ops)
+ })
+ // Trigger a sweep of our stream controller. Doing this once per frame allows
+ // us to gracefully start and stop UI-driven streams of data from our backend
+ // without manually managing their lifecycle. If we sweep twice and a given stream
+ // was not used between them, we can conclude that it is not powering an active
+ // portion of the UI and shut it down for now.
+ // All that you really need to remember is that this must be called once per frame.
+ u.controller.Sweep()
+ })
}
}
return nil