ThomazPom / Moz-Ext-UltimaDark

Web Extension that uses agressive technique to get dark mode everywhere
12 stars 3 forks source link

ImageEdition Rewrite #41

Open Vintagemotors opened 6 months ago

Vintagemotors commented 6 months ago

Example: https://sourceforge.net/projects/abaguibuilder/

Not quite the same issue but close enough; eBay logo is lightened when UltimaDark is enabled: https://www.ebay.com/

ThomazPom commented 6 months ago

I'm unable to replicate this issue. Could you share a screenshot for clarification?

By the way, thank you for submitting your issues along with helpful examples. I greatly appreciate it.

Vintagemotors commented 6 months ago

Update: It appears to be caused by leaving "Image Edition" enabled

Enabled image

Enabled and scrolled image

Image Edition Disabled image

Image Edition Disabled scrolled image

Update: just tested on another system with Firefox 121.0 stable plus 1.5.21 and it is exhibiting the previous behavior during scrolling so the blank page with Image Edition appears to be specific to 122.0b3

ThomazPom commented 6 months ago

I'm still unable to reproduce, but 'im very curious about this one. Could you please share your Firefox build and version?

ThomazPom commented 6 months ago

Not quite the same issue but close enough; eBay logo is lightened when UltimaDark is enabled: https://www.ebay.com/

The image editing feature is currently capable of adjusting both background images for darkening and other images for brightening. However, it requires intelligence to determine whether to brighten, darken, reduce luminance, leave untouched, or categorize under other criteria (categories are still to define ). In the case of this eBay logo, "untouched" could be a good choice.

Vintagemotors commented 6 months ago

I just had the entire page refuse to load on 1.5.21 with new errors! Looks like this is going to be a fun one. Steps to reproduce: go to this issue on Github, enable UltimaDark, Cache system, and Image edition, right click open the sourceforge link in new tab and the page is blank. disable everything close the tab and reopen the tab to fix

Screenshot_2023-12-28_160134 Screenshot_2023-12-28_160229

Vintagemotors commented 6 months ago

I'm still unable to reproduce, but 'im very curious about this one. Could you please share your Firefox build and version?

I'm on Firefox Developer Edition 122.0b3

Vintagemotors commented 6 months ago

Shown on 121.0 Stable, it didn't capture the extension window but I start with image edition enabled, disable it and refresh, then enable it again and refresh to show that it is repeatable - video is too big for Github

video that refuses to embed inline: https://cdn.discordapp.com/attachments/624403666425872405/1190055863948415106/Abacus_Java_GUI_Builder_download___SourceForge.net_Mozilla_Firefox_2023-12-28_16-15-02.mp4

ThomazPom commented 6 months ago

The error you have there, "last_rule" not defined, is an error that I theorized but believed to be impossible. I'm adding a test to cover it and a message in the inspector to try to understand in what incredibly rare case it can occur. However, I have the feeling that it is not the only thing that can cause long page loading times so regularly, given the high level of improbability of this error.

Good one !

ThomazPom commented 6 months ago

1.5.21 was too buggy for a release, it was breaking so much websites i had to publish 1.5.22 as a rollback

Vintagemotors commented 6 months ago

1.5.21 was too buggy for a release, it was breaking so much websites i had to publish 1.5.22 as a rollback

Bummer, I was using it and it seemed decent on stable - less so on Developer...

Vintagemotors commented 6 months ago

This is an ImageEditionBug

Edit: I see that I can fix that myself now - thanks! I'll do what I can to help :)

Vintagemotors commented 6 months ago

Bump: it is still present in 1.5.28

ThomazPom commented 6 months ago

https://www.alltricks.fr/26-x-1.2.sdex

ThomazPom commented 6 months ago

Discovered it is due to a miscalculation in SVG images with the current image editing system. Since i'm planning a complete recoding of it for many reasons, there's no need to search and fix it now. (The proof of the new method's functionality is ready here)

ThomazPom commented 5 months ago

Hi @Vintagemotors,

I've initiated the rework of the ImageEdition feature in this commit. Feel free to build and test it using the following link: ImageEdition Commit.

Please note that remote SVGs haven't been incorporated yet, so certain icons may appear black.

Image classifications is inherently challenging, and perfection in rule definition is elusive. As of now, the rules are as follows:

If the filename matches /background|(?<![a-z])(bg|box|panel|fond|fundo|bck)(?![a-z])/i: it is considered a background.

If the filename includes "logo," or has "logo" in its class, or is within a link tag: it is identified as a logo.

If the image is not styled with width and height expressed in percentages, and the width or height matches the real image size, it is not deemed a background (likely somepthing the website want us to see, like an article).

If the image has a background repeat, or if the alternative text includes "background," or if the filename includes "sprite": it is identified as a background.

If three or more of the six main lines of the image are gradients or achromatic without alpha, it is classified as a background unless there is a fully transparent line.

If an image has more than 1900 unique colors or more than 500 different pixels in brightness, it is recognized as a picture, not a background.

Additionally, for images meeting specific criteria, a set of rules applies:

If the image contrast is > 0.77, avg lightness / 255 > 220, and max lightness > 204, the image is inverted.

If the image has more than one color:
    If alpha percentage is > 10% and the number of alpha pixels * 2 is greater than the image pixel count, it is not a background (likely a logo).
    If avg lightness < 255*0.4 and max lightness < 255*0.4, If it's a background it is dark and has no contrast, there's no need to darken it further.
    If contrast percent > 0.45 and avg lightness > 127, or contrast percent > 0.60, it is bright but seems to have contrast elements; darkening it may result in losing these elements.

Another long set of rules specifically applies to logo transformations.

Until the option is available UltimaDark now forces the websites to lazy load their images to enhance page load speed. Given the resource-intensive nature of image analysis and editing, this adjustment aims to optimize the overall loading time of the website.

Vintagemotors commented 5 months ago

I was unable to produce a build that did not say it "appears to be corrupt". I tried both the build script and doing it manually as outlined on the wiki. Both had the same result. Update: it was a signature issue. By clicking "load temporary add-on" from the debugging page it was able to load.

Vintagemotors commented 5 months ago

The images are never loading so probably don't release 1.5.37 yet. It's also failing to darken the page at all on Soundcloud with Firefox Developer Edition while that aspect is working fine on the updated version of Floorp for whatever reason.

Log TypeError: can't access property "id", connectedPort.sender.tab is undefined [background.js:1686:41](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/background.js) Unknown property ‘tap-highlight-color’. Declaration dropped. [_generated_background_page.html:1:4022](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Error in parsing value for ‘display’. Declaration dropped. [_generated_background_page.html:1:1731](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Unknown property ‘-moz-text-decoration’. Declaration dropped. [_generated_background_page.html:1:1952](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Error in parsing value for ‘box-shadow’. Declaration dropped. [_generated_background_page.html:1:1776](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Unknown property ‘tap-highlight-color’. Declaration dropped. [_generated_background_page.html:1:2105](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Error in parsing value for ‘outline’. Declaration dropped. [_generated_background_page.html:1:275](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Error in parsing value for ‘box-shadow’. Declaration dropped. [_generated_background_page.html:1:94](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Unknown property ‘tap-highlight-color’. Declaration dropped. [_generated_background_page.html:1:74](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Unknown property ‘tap-highlight-color’. Declaration dropped. [_generated_background_page.html:1:114](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Unknown property ‘align’. Declaration dropped. [_generated_background_page.html:1:4303](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Unknown property ‘padding_top’. Declaration dropped. [_generated_background_page.html:1:6891](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Unknown property ‘font-smoothing’. Declaration dropped. [_generated_background_page.html:1:26667](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Error in parsing value for ‘animation’. Declaration dropped. [_generated_background_page.html:1:27846](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:14](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:132](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:13](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:17](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:16](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. 2 [_generated_background_page.html:1:13](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. 4 [_generated_background_page.html:1:13](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. 17 [_generated_background_page.html:1:13](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. 13 [_generated_background_page.html:1:13](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:26](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:71](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:13](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:132](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:25](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:12](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:19](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:25](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:18](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:13](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:132](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:12](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:139](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:23](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:18](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:21](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:12](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:139](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:23](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:18](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:21](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:12](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:139](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:23](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:18](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:21](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:12](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:139](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:23](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:18](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:21](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:12](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:139](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:23](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:18](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:21](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:12](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:139](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:23](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:18](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html) Ruleset ignored due to bad selector. [_generated_background_page.html:1:40](moz-extension://efcca830-448a-413d-bada-e03ef4df15bd/_generated_background_page.html)
ThomazPom commented 5 months ago

I know the build is very far from distribuable, i just wanted to save my work, it took days to get to this point 😅

ThomazPom commented 5 months ago

I have good news ,I've identified and resolved the root cause of the sluggish performance in the image editing feature. My code is messy again, but I'm happy it's running so fast.