xpra icon
Bug tracker and wiki

Ticket #999: delay-refresh.patch

File delay-refresh.patch, 3.9 KB (added by Antoine Martin, 19 months ago)

delay refresh

  • xpra/server/window/video_subregion.py

     
    7979        #keep track of how much extra we batch non-video regions (milliseconds):
    8080        self.non_max_wait = 150
    8181        self.min_time = monotonic_time()
     82        self.min_refresh_time = 0
    8283
    8384    def reset(self):
    8485        self.cancel_refresh_timer()
     
    150151                     "set-at"       : self.set_at,
    151152                     "time"         : int(self.time),
    152153                     "min-time"     : int(self.min_time),
     154                     "min-refresh-time"  : int(self.min_refresh_time),
    153155                     "non-max-wait" : self.non_max_wait,
    154156                     "in-out"       : self.inout,
    155157                     "score"        : self.score,
     
    191193        for r in self.refresh_regions:
    192194            if not rect.contains_rect(r):
    193195                non_video += r.substract_rect(rect)
    194         delay = max(150, self.auto_refresh_delay)
     196        now = monotonic_time()
     197        delay = max(150, self.min_refresh_time-now, self.auto_refresh_delay)
    195198        if non_video:
    196199            #refresh via timeout_add so this will run in the UI thread:
    197200            self.timeout_add(delay, self.refresh_cb, non_video)
     
    200203            self.refresh_regions = [r for r in inrect if r is not None]
    201204        #re-schedule the video region refresh (if we have regions to fresh):
    202205        if self.refresh_regions:
    203             self.refresh_timer = self.timeout_add(delay, self.refresh)
     206            pass
     207            #self.refresh_timer = self.timeout_add(delay, self.refresh)
    204208
    205209    def refresh(self):
    206210        #runs via timeout_add, safe to call UI!
     
    216220        refreshlog("refresh() calling %s with regions=%s", self.refresh_cb, regions)
    217221        self.refresh_cb(regions)
    218222
     223    def reschedule_refresh(self):
     224        rt = self.refresh_timer
     225        if rt:
     226            self.source_remove(rt)
     227            now = monotonic_time()
     228            delay = max(150, self.min_refresh_time-now, self.auto_refresh_delay)
     229            self.refresh_timer = self.timeout_add(delay, self.refresh)
    219230
     231
    220232    def novideoregion(self, msg="", *args):
    221233        sslog("novideoregion: "+msg, *args)
    222234        self.rectangle = None
  • xpra/server/window/window_source.py

     
    18151815            statslog("record_congestion_event(%i) %iKbps", late_pct, send_speed/1024)
    18161816            gs.congestion_send_speed.append((now, late_pct, send_speed))
    18171817            gs.last_congestion_time = now
     1818        self.delay_refresh(5)
    18181819
     1820    def delay_refresh(self, delay):
     1821        log.info("delay_refresh(%i)", delay)
     1822        #push it back:
     1823        rtt = self.refresh_target_time
     1824        if rtt:
     1825            self.refresh_target_time = rtt+delay
     1826
     1827
    18191828    def damage_packet_acked(self, damage_packet_sequence, width, height, decode_time, message):
    18201829        """
    18211830            The client is acknowledging a damage packet,
  • xpra/server/window/window_video_source.py

     
    545545        WindowSource.timer_full_refresh(self)
    546546
    547547
     548    def delay_refresh(self, delay):
     549        WindowSource.delay_refresh(self, delay)
     550        self.video_subregion.min_refresh_time = monotonic_time()+delay
     551        self.video_subregion.reschedule_refresh()
     552
     553
    548554    def get_refresh_exclude(self):
    549555        #exclude video region (if any) from lossless refresh:
    550556        return self.video_subregion.rectangle