@@ -222,7 +222,8 @@ func (w *dashboardWindow) imagesLayer(width, height int) (_ret image.Image) {
222
222
ctx := context .TODO ()
223
223
logger .Tracef (ctx , "imagesLayer(%d, %d)" , width , height )
224
224
defer func () { logger .Tracef (ctx , "/imagesLayer(%d, %d): size:%v" , width , height , _ret .Bounds ()) }()
225
- return xsync .DoR1 (xsync .WithNoLogging (ctx , true ), & w .imagesLocker , func () image.Image {
225
+ ctx = xsync .WithNoLogging (ctx , true )
226
+ return xsync .DoR1 (ctx , & w .imagesLocker , func () image.Image {
226
227
return w .renderImagesNoLock (ctx , width , height )
227
228
})
228
229
}
@@ -259,6 +260,7 @@ func (w *dashboardWindow) renderImagesNoLock(
259
260
260
261
canvasRatio := float64 (dstSize .X ) / float64 (dstSize .Y )
261
262
263
+ logger .Tracef (ctx , "len(w.changedImages) == %d" , len (w .changedImages ))
262
264
imgIsChanged := map [string ]struct {}{}
263
265
for _ , img := range w .changedImages {
264
266
if dashboardDebug {
@@ -577,7 +579,7 @@ func (w *dashboardWindow) startUpdatingNoLock(
577
579
w .renderStreamStatus (ctx )
578
580
579
581
observability .Go (ctx , func () {
580
- t := time .NewTicker (500 * time .Millisecond )
582
+ t := time .NewTicker (1000 * time .Millisecond )
581
583
for {
582
584
select {
583
585
case <- ctx .Done ():
@@ -645,8 +647,8 @@ func (w *dashboardWindow) updateImages(
645
647
ctx context.Context ,
646
648
dashboardCfg streamdconfig.DashboardConfig ,
647
649
) {
648
- logger .Tracef (ctx , "updateImages" )
649
- defer logger .Tracef (ctx , "/updateImages" )
650
+ logger .Debugf (ctx , "updateImages" )
651
+ defer logger .Debugf (ctx , "/updateImages" )
650
652
651
653
w .dashboardLocker .Do (ctx , func () {
652
654
w .updateImagesNoLock (ctx , dashboardCfg )
@@ -772,12 +774,9 @@ func (w *dashboardWindow) updateImagesNoLock(
772
774
if ! changed && lastWinSize == winSize && lastOrientation == orientation {
773
775
return
774
776
}
775
- logger .Tracef (
776
- ctx ,
777
+ logger .Tracef (ctx ,
777
778
"updating the screenshot image: %v %#+v %#+v" ,
778
- changed ,
779
- lastWinSize ,
780
- winSize ,
779
+ changed , lastWinSize , winSize ,
781
780
)
782
781
b := img .Bounds ()
783
782
m := image .NewNRGBA (image .Rect (0 , 0 , b .Dx (), b .Dy ()))
@@ -787,18 +786,27 @@ func (w *dashboardWindow) updateImagesNoLock(
787
786
el = elementsMap [screenshotElementName ]
788
787
el .Image = m
789
788
})
789
+ logger .Tracef (ctx , "push screenshot to changedElements" )
790
790
changedElements <- el
791
791
})
792
- w .changedImages = w .changedImages [:0 ]
792
+
793
+ var receiverWG sync.WaitGroup
793
794
changedCount := 0
794
- go func () {
795
- for el := range changedElements {
796
- changedCount ++
797
- w .changedImages = append (w .changedImages , el )
798
- }
799
- }()
795
+ w .imagesLocker .Do (xsync .WithNoLogging (ctx , true ), func () {
796
+ w .changedImages = w .changedImages [:0 ]
797
+ receiverWG .Add (1 )
798
+ go func () {
799
+ defer receiverWG .Done ()
800
+ for el := range changedElements {
801
+ logger .Tracef (ctx , "<-changedElement: %s" , el .ElementName )
802
+ changedCount ++
803
+ w .changedImages = append (w .changedImages , el )
804
+ }
805
+ }()
806
+ })
800
807
wg .Wait ()
801
808
close (changedElements )
809
+ receiverWG .Wait ()
802
810
803
811
if changedCount > 0 {
804
812
w .imagesLayerObj .Refresh ()
0 commit comments