html - SVG filter artifacts when removing CSS property -


context

i working on browser extension, night video tuner, injects svg filters html pages using javascript, in order filter out blue light videos. here example of svg filter generated extension like:

<svg xmlns="http://www.w3.org/2000/svg">   <filter id="temperature_filter" style="display: none;">     <fecolormatrix type="matrix" values="1 0 0 0 0 0 0.6949030005552019 0 0 0 0 0 0.4310480202110507 0 0 0 0 0 1 0"></fecolormatrix>   </filter> </svg> 

style="display: none;" used prevent svg element affecting layout of page.

i adding filter: url(#temperature_filter) property style attribute of video element found in current html page in order apply svg filter media content. here small fiddle showcasing similar setup, video , filter applied it.

issue

so far approach working charm on chrome , opera. unfortunately, due bug in firefox, cannot use style="display: none;" property browser , looking applying workarounds suggested other stack overflow question instead.

i noticed overall quality of svg filter degraded in firefox, visual artifacts appearing, in darker parts of video. case when remove style="display: none;" filter in opera , chrome, suggests property linked filter no longer rendering properly. here example, on left hand side filter without style="display: none;", , on right hand side filter property, resulting in stronger , smoother filter:

filters

i using latest version of opera, firefox , chrome on windows, , happens regardless of hardware acceleration being enabled or not.

questions

  • why absence of style="display: none;" cause filter rendered poorly?

  • is there workaround render filter correctly in firefox, style="display: none;" cannot used in context?

thanks in advance, appreciated!

in svg, filters supposed using linear rgb colour space default. appears if chrome hardwired using srgb colour space when fi;ltering <video> elements. i'm not sure why - it's possibly/probably bug.

you can firefox behave same chrome, specifying

color-interpolation-filters="srgb" 

on filter. unfortunately, chrome ignores if try force use linearrgb colour space (color-interpolation-filters="linearrgb").

and can hide svg filter in page specifying 0 width , height on <svg> element.

<video autoplay controls muted src=" https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" style="width: 488px; height: 360px; filter: url(#temperature_filter)">  </video>    <svg xmlns="http://www.w3.org/2000/svg" width="0" height="0">    <filter id="temperature_filter" color-interpolation-filters="srgb">      <fecolormatrix type="matrix" values="1 0 0 0 0 0 0.694 0 0 0 0 0 0.431 0 0 0 0 0 1 0"></fecolormatrix>    </filter>  </svg>

https://jsfiddle.net/fyy5wrkw/8/


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -