@@ -90,7 +90,6 @@ export class TimelineDetailsPane extends
9090 #parsedTrace: Trace . Handlers . Types . ParsedTrace | null = null ;
9191 #traceInsightsSets: Trace . Insights . Types . TraceInsightSets | null = null ;
9292 #eventToRelatedInsightsMap: TimelineComponents . RelatedInsightChips . EventToRelatedInsightsMap | null = null ;
93- #filmStrip: Trace . Extras . FilmStrip . Data | null = null ;
9493 #onTraceBoundsChangeBound = this . #onTraceBoundsChange. bind ( this ) ;
9594 #thirdPartyTree = new ThirdPartyTreeViewWidget ( ) ;
9695 #entityMapper: Utils . EntityMapper . EntityMapper | null = null ;
@@ -286,7 +285,7 @@ export class TimelineDetailsPane extends
286285 this . #parsedTrace = data . parsedTrace ;
287286 }
288287 if ( data . parsedTrace ) {
289- this . #filmStrip = Trace . Extras . FilmStrip . fromParsedTrace ( data . parsedTrace ) ;
288+ this . #summaryContent . filmStrip = Trace . Extras . FilmStrip . fromParsedTrace ( data . parsedTrace ) ;
290289 this . #entityMapper = new Utils . EntityMapper . EntityMapper ( data . parsedTrace ) ;
291290 }
292291 this . #selectedEvents = data . selectedEvents ;
@@ -398,26 +397,7 @@ export class TimelineDetailsPane extends
398397 this . updateContents ( ) ;
399398 }
400399
401- #getFilmStripFrame( frame : Trace . Types . Events . LegacyTimelineFrame ) : Trace . Extras . FilmStrip . Frame | null {
402- if ( ! this . #filmStrip) {
403- return null ;
404- }
405-
406- const screenshotTime = ( frame . idle ? frame . startTime : frame . endTime ) ;
407- const filmStripFrame = Trace . Extras . FilmStrip . frameClosestToTimestamp ( this . #filmStrip, screenshotTime ) ;
408- if ( ! filmStripFrame ) {
409- return null ;
410- }
411-
412- const frameTimeMilliSeconds = Trace . Helpers . Timing . microToMilli ( filmStripFrame . screenshotEvent . ts ) ;
413- const frameEndTimeMilliSeconds = Trace . Helpers . Timing . microToMilli ( frame . endTime ) ;
414- return frameTimeMilliSeconds - frameEndTimeMilliSeconds < 10 ? filmStripFrame : null ;
415- }
416-
417- #setSelectionForTimelineFrame( frame : Trace . Types . Events . LegacyTimelineFrame ) : void {
418- const matchedFilmStripFrame = this . #getFilmStripFrame( frame ) ;
419- void this . updateSummaryAndSelectTab (
420- TimelineUIUtils . generateDetailsContentForFrame ( frame , this . #filmStrip, matchedFilmStripFrame ) ) ;
400+ #addLayerTreeForSelectedFrame( frame : Trace . Types . Events . LegacyTimelineFrame ) : void {
421401 const target = SDK . TargetManager . TargetManager . instance ( ) . rootTarget ( ) ;
422402 if ( frame . layerTree && target ) {
423403 const layerTreeForFrame = new TracingFrameLayerTree ( target , frame . layerTree ) ;
@@ -462,10 +442,10 @@ export class TimelineDetailsPane extends
462442 this . updateContentsScheduled = false ;
463443
464444 if ( Trace . Types . Events . isLegacyTimelineFrame ( selection . event ) ) {
465- this . #setSelectionForTimelineFrame( selection . event ) ;
466- } else {
467- await this . #setSelectionForTraceEvent( selection . event ) ;
445+ this . #addLayerTreeForSelectedFrame( selection . event ) ;
468446 }
447+
448+ await this . #setSelectionForTraceEvent( selection . event ) ;
469449 } else if ( selectionIsRange ( selection ) ) {
470450 const timings = Trace . Helpers . Timing . traceWindowMicroSecondsToMilliSeconds ( selection . bounds ) ;
471451 this . updateSelectedRangeStats ( timings . min , timings . max ) ;
@@ -629,6 +609,7 @@ interface SummaryViewInput {
629609 entityMapper : Utils . EntityMapper . EntityMapper | null ;
630610 target : SDK . Target . Target | null ;
631611 linkifier : Components . Linkifier . Linkifier | null ;
612+ filmStrip : Trace . Extras . FilmStrip . Data | null ;
632613}
633614
634615type View = ( input : SummaryViewInput , output : object , target : HTMLElement ) => void ;
@@ -659,6 +640,7 @@ class SummaryView extends UI.Widget.Widget {
659640 entityMapper : Utils . EntityMapper . EntityMapper | null = null ;
660641 target : SDK . Target . Target | null = null ;
661642 linkifier : Components . Linkifier . Linkifier | null = null ;
643+ filmStrip : Trace . Extras . FilmStrip . Data | null = null ;
662644
663645 constructor ( element ?: HTMLElement , view = SUMMARY_DEFAULT_VIEW ) {
664646 super ( element ) ;
@@ -676,6 +658,7 @@ class SummaryView extends UI.Widget.Widget {
676658 entityMapper : this . entityMapper ,
677659 target : this . target ,
678660 linkifier : this . linkifier ,
661+ filmStrip : this . filmStrip
679662 } ,
680663 { } , this . contentElement ) ;
681664 }
@@ -721,9 +704,43 @@ async function renderSelectedEventDetails(
721704 // clang-format on
722705 }
723706
707+ if ( Trace . Types . Events . isLegacyTimelineFrame ( selectedEvent ) && input . filmStrip ) {
708+ const matchedFilmStripFrame = getFilmStripFrame ( input . filmStrip , selectedEvent ) ;
709+ const content =
710+ TimelineUIUtils . generateDetailsContentForFrame ( selectedEvent , input . filmStrip , matchedFilmStripFrame ) ;
711+ return html `${ content } ` ;
712+ }
713+
724714 // Fall back to the default trace event details. Long term this needs to use
725715 // the UI Eng Vision.
726716 const traceEventDetails =
727717 await TimelineUIUtils . buildTraceEventDetails ( parsedTrace , selectedEvent , linkifier , true , input . entityMapper ) ;
728718 return html `${ traceEventDetails } ` ;
729719}
720+
721+ const filmStripFrameCache = new WeakMap < Trace . Types . Events . LegacyTimelineFrame , Trace . Extras . FilmStrip . Frame | null > ( ) ;
722+
723+ function getFilmStripFrame ( filmStrip : Trace . Extras . FilmStrip . Data , frame : Trace . Types . Events . LegacyTimelineFrame ) :
724+ Trace . Extras . FilmStrip . Frame | null {
725+ const fromCache = filmStripFrameCache . get ( frame ) ;
726+ if ( typeof fromCache !== 'undefined' ) {
727+ return fromCache ;
728+ }
729+
730+ const screenshotTime = ( frame . idle ? frame . startTime : frame . endTime ) ;
731+ const filmStripFrame = Trace . Extras . FilmStrip . frameClosestToTimestamp ( filmStrip , screenshotTime ) ;
732+ if ( ! filmStripFrame ) {
733+ filmStripFrameCache . set ( frame , null ) ;
734+ return null ;
735+ }
736+
737+ const frameTimeMilliSeconds = Trace . Helpers . Timing . microToMilli ( filmStripFrame . screenshotEvent . ts ) ;
738+ const frameEndTimeMilliSeconds = Trace . Helpers . Timing . microToMilli ( frame . endTime ) ;
739+ if ( frameTimeMilliSeconds - frameEndTimeMilliSeconds < 10 ) {
740+ filmStripFrameCache . set ( frame , filmStripFrame ) ;
741+ return filmStripFrame ;
742+ }
743+
744+ filmStripFrameCache . set ( frame , null ) ;
745+ return null ;
746+ }
0 commit comments