xpra icon
Bug tracker and wiki

Ticket #756: delta-free-buckets.patch

File delta-free-buckets.patch, 6.0 KB (added by Antoine Martin, 4 years ago)

frees buckets as needed - not sure this is worth doing

  • xpra/client/gtk_base/gtk_client_base.py

     
    238238        capabilities["encoding.icons.max_size"] = 128, 128      #limit
    239239        from xpra.client.window_backing_base import DELTA_BUCKETS
    240240        capabilities["encoding.delta_buckets"] = DELTA_BUCKETS
     241        capabilities["encoding.delta_free"] = True
    241242        return capabilities
    242243
    243244
  • xpra/client/window_backing_base.py

     
    454454        """ dispatches the paint to one of the paint_XXXX methods """
    455455        log("draw_region(%s, %s, %s, %s, %s, %s bytes, %s, %s, %s)", x, y, width, height, coding, len(img_data), rowstride, options, callbacks)
    456456        coding = bytestostr(coding)
     457        #deal with delta freeeing:
     458        for bucket in options.listget("delta_free", []):
     459            self._delta_pixel_data[bucket] = None
     460            log.info("freed bucket %s", bucket)
    457461        options["encoding"] = coding            #used for choosing the color of the paint box
    458462        if coding == "mmap":
    459463            self.idle_add(self.paint_mmap, img_data, x, y, width, height, rowstride, options, callbacks)
  • xpra/server/window_source.py

     
    112112            self.supports_delta = [x for x in encoding_options.strlistget("supports_delta", []) if x in ("png", "rgb24", "rgb32")]
    113113            if self.supports_delta:
    114114                self.delta_buckets = encoding_options.intget("delta_buckets", 1)
     115                self.delta_free = encoding_options.boolget("delta_free")
    115116                self.delta_pixel_data = [None for _ in range(self.delta_buckets)]
    116117        self.batch_config = batch_config
    117118        #auto-refresh:
     
    209210        self.full_frames_only = False
    210211        self.supports_delta = []
    211212        self.delta_buckets = 0
     213        self.delta_free = False
     214        self.delta_tell_free = set()
    212215        self.delta_pixel_data = []
    213216        self.suspended = False
    214217        self.strict = STRICT_MODE
     
    293296                "supports-transparency" : self.supports_transparency,
    294297                "delta"                 : self.supports_delta,
    295298                "delta.buckets"         : self.delta_buckets,
     299                "delta.free"            : self.delta_free,
    296300                })
    297301        now = time.time()
    298302        for i,x in enumerate(self.delta_pixel_data):
     
    501505        if self.encoding==encoding:
    502506            return
    503507        self.statistics.reset()
    504         self.delta_pixel_data = [None for _ in range(self.delta_buckets)]
     508        self.free_all_delta()
    505509        self.update_encoding_selection(encoding)
    506510
     511    def free_all_delta(self):
     512        x = range(self.delta_buckets)
     513        self.delta_tell_free = set(x)
     514        self.delta_pixel_data = [None for _ in x]
    507515
     516
    508517    def update_encoding_selection(self, encoding=None):
    509518        #now we have the real list of encodings we can use:
    510519        #"rgb32" and "rgb24" encodings are both aliased to "rgb"
     
    634643        self.refresh_regions = []
    635644        self._damage_delayed = None
    636645        self._damage_delayed_expired = False
    637         self.delta_pixel_data = [None for _ in range(self.delta_buckets)]
     646        self.free_all_delta()
    638647        #make sure we don't account for those as they will get dropped
    639648        #(generally before encoding - only one may still get encoded):
    640649        for sequence in self.statistics.encoding_pending.keys():
     
    13941403    def client_decode_error(self, error):
    13951404        self.global_statistics.decode_errors += 1
    13961405        #something failed client-side, so we can't rely on the delta being available
    1397         self.delta_pixel_data = [None for _ in range(self.delta_buckets)]
     1406        self.free_all_delta()
    13981407
    13991408
    14001409    def make_data_packet(self, damage_time, process_damage_time, wid, image, coding, sequence, options):
     
    14811490                #compressed size is more than 33% of the original
    14821491                #maybe delta is not helping us, so clear it:
    14831492                self.delta_pixel_data[bucket] = None
    1484                 #TODO: could tell the clients they can clear it too
     1493                self.delta_tell_free.add(bucket)
     1494                #tell the clients they can clear it too
     1495                #client_options["               
    14851496                #(add a new client capability and send it a zero store value)
    14861497            else:
    14871498                #find the bucket to use:
     
    14981509                                t = dr[-1]
    14991510                                bucket = i
    15001511                self.delta_pixel_data[bucket] = [w, h, coding, store, dpixels, time.time()]
     1512                if bucket in self.delta_tell_free:
     1513                    #need try / except because of threading races:
     1514                    try:
     1515                        self.delta_tell_free.remove(bucket)
     1516                    except:
     1517                        pass
    15011518                client_options["store"] = store
    15021519                client_options["bucket"] = bucket
    15031520                #record number of frames and pixels:
     
    15091526        if not self.generic_encodings:
    15101527            #old clients use non-generic encoding names:
    15111528            encoding = NEW_ENCODING_NAMES_TO_OLD.get(coding, coding)
     1529        if self.delta_free and self.delta_tell_free:
     1530            #we can tell the client to free some buckets
     1531            dtf = list(self.delta_tell_free)
     1532            self.delta_tell_free = set()
     1533            client_options["delta_free"] = dtf
    15121534        #actual network packet:
    15131535        packet = ("draw", wid, x, y, outw, outh, encoding, data, self._damage_packet_sequence, outstride, client_options)
    15141536        end = time.time()