microsoft / vscode

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

missing icons due to wrong svg content type #97564

Closed chavaroon closed 3 years ago

chavaroon commented 4 years ago

Issue Type: Bug

Try to set File Icon Theme to other than Seti (Visual Studio Code), and file icons will show no icons (or an empty tab space as icon). Also, somehow the root cause affected my 'Bookmarks' Extension which shows no icon.

Anotación 2020-05-11 200509

I've downgraded VSCode to version 1.42, and the issue is not present there. I'm pretty sure the issue is not related to VSCode version, as I have installed the latest version to another PC, and the issue is not present there.

I've also reinstalled VSCode as many as four or five times, deleting some tmp files from VSCode, but have not got rid of the issue.

VS Code version: Code 1.45.0 (d69a79b73808559a91206d73d7717ff5f798f23c, 2020-05-07T16:18:48.860Z) OS version: Windows_NT x64 10.0.17763

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz (8 x 1896)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|7.85GB (1.98GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
Extensions (6) Extension|Author (truncated)|Version ---|---|--- Bookmarks|ale|11.2.0 bracket-pair-colorizer|Coe|1.0.61 python|ms-|2020.4.76186 cpptools|ms-|0.28.0-insiders3 vscode-icons|vsc|10.1.1 srecord|xia|0.0.3
aeschli commented 4 years ago

Maybe a dup of https://github.com/microsoft/vscode/issues/92323

From https://github.com/microsoft/vscode/issues/92323#issuecomment-611045838:

Can you check

chavaroon commented 4 years ago

Ok, saw #92323.

Thank you, so much.!

EDIT:

aeschli commented 4 years ago

@deepak1556 @sandy081 This issue has been reported several times.

Any chance we can force Electron to use 'our' content types? For VSCode as a application, there's no point of using a custom content types for svg images.

deepak1556 commented 4 years ago

Yup we can, we already do something close enough to block svg images from remote urls https://github.com/microsoft/vscode/blob/master/src/vs/code/electron-main/window.ts#L404-L413 . We can modify the condition a bit for local urls and edit the content-type in onHeadersReceived. The headers received in this method are from network layer before they have reached the renderer, so any response modified here will only be used for further processing by the renderer.

if (details.url.indexOf('.svg') > 0) {
   const uri = URI.parse(details.url);
   // I assume the svg are currently served over file
  // If its vscode-resource, change condition according to the scheme
   if (uri && uri.scheme.match(/file/i)) {
      responseHeaders['content-type'] = 'image/svg+xml'
      return callback({ cancel: false, ...responseHeaders });
   }
}
wmertens commented 4 years ago

Triage: if this is indeed a dup of #92323, perhaps this issue can be closed?

deepak1556 commented 4 years ago

@wmertens this issue tracks the solution to prevent svg being loaded with incorrect Content-Type headers.

aeschli commented 3 years ago

I still see the issue in Version: 1.53.0-insider (user setup) Commit: 5a52bc29d5e9bc419077552d336ea26d904299fa Date: 2021-01-29T05:13:48.533Z Electron: 11.2.1 OS: Windows_NT x64 10.0.19042

deepak1556 commented 3 years ago

/cc @rzhao271

jblievremont commented 3 years ago

I have an issue that looks similar with VSCode 1.53.2 on Ubuntu 20.04: the SVG icons I use in an extension, on both tree view items and inside webviews, don't show.

Their PNG equivalents show, so it seems that SVG is specifically blocked (confirmed by the Webview Development Tools that show a download size of "0 B" for the SVG).

Could it be related, or shall I open another ticket?

OmarOdaini commented 3 years ago

Hi guys, can someone point me to a similar fix on mac. I have this issue with my docker extension. thanks

aeschli commented 3 years ago

This should be fixed since a while. If you still see it, please follow the steps in https://github.com/microsoft/vscode/issues/97564#issuecomment-627292788

If that doesn't help or apply, please file a new issue.

rzhao271 commented 2 years ago

The current mitigation is https://github.com/microsoft/vscode/issues/97564#issuecomment-627351149 I used those steps to intentionally change the type back to text/xml, and I noticed that the issue still repros.