microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.77k stars 28.73k forks source link

Renderer freezes briefly if a large image is pasted in chat #229619

Closed connor4312 closed 2 hours ago

connor4312 commented 4 hours ago

Testing #229263

  1. Copy a large image (cat)
  2. Paste it into chat
  3. The window freezes for a few seconds

Seems we spent in the objectHash function

Image

justschen commented 4 hours ago

cc. @Tyriar is there a compromise on what we hash for the ID? ie, maybe half of the bytes instead of the full thing, or something of the sort, since ATM we are just hashing the entire received UInt8Array

connor4312 commented 4 hours ago

It looks like the function is trying to hash the Uint8Array naively as an object (hashing each key and value for each element in the array) which is going to be extraordinarily slow. crypto.subtle.digest should complete in millisecond(s) :)