Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageEdition Rewrite #41

Open
Vintagemotors opened this issue Dec 26, 2023 · 19 comments
Open

ImageEdition Rewrite #41

Vintagemotors opened this issue Dec 26, 2023 · 19 comments
Labels
ImageEditionBug Something isn't working with highly experimental ImageEdition feature

Comments

@Vintagemotors
Copy link
Collaborator

Vintagemotors commented Dec 26, 2023

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
Copy link
Owner

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
Copy link
Collaborator Author

Vintagemotors commented Dec 26, 2023

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
Copy link
Owner

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

@ThomazPom
Copy link
Owner

ThomazPom commented Dec 28, 2023

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

Vintagemotors commented Dec 28, 2023

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

Vintagemotors commented Dec 30, 2023

This is an ImageEditionBug

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

@Vintagemotors Vintagemotors added the ImageEditionBug Something isn't working with highly experimental ImageEdition feature label Dec 30, 2023
@Vintagemotors
Copy link
Collaborator Author

Bump: it is still present in 1.5.28

@ThomazPom
Copy link
Owner

@ThomazPom
Copy link
Owner

ThomazPom commented Jan 14, 2024

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)

@Vintagemotors Vintagemotors changed the title Some websites exhibit distorted logos that stay at the top of the page when scrolling while they shouldn't ImageEditionRewrite Jan 18, 2024
@Vintagemotors Vintagemotors changed the title ImageEditionRewrite ImageEdition Rewrite Jan 18, 2024
@ThomazPom
Copy link
Owner

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
Copy link
Collaborator Author

Vintagemotors commented Jan 23, 2024

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
Copy link
Collaborator Author

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
Unknown property ‘tap-highlight-color’. Declaration dropped. _generated_background_page.html:1:4022
Error in parsing value for ‘display’. Declaration dropped. _generated_background_page.html:1:1731
Unknown property ‘-moz-text-decoration’. Declaration dropped. _generated_background_page.html:1:1952
Error in parsing value for ‘box-shadow’. Declaration dropped. _generated_background_page.html:1:1776
Unknown property ‘tap-highlight-color’. Declaration dropped. _generated_background_page.html:1:2105
Error in parsing value for ‘outline’. Declaration dropped. _generated_background_page.html:1:275
Error in parsing value for ‘box-shadow’. Declaration dropped. _generated_background_page.html:1:94
Unknown property ‘tap-highlight-color’. Declaration dropped. _generated_background_page.html:1:74
Unknown property ‘tap-highlight-color’. Declaration dropped. _generated_background_page.html:1:114
Unknown property ‘align’. Declaration dropped. _generated_background_page.html:1:4303
Unknown property ‘padding_top’. Declaration dropped. _generated_background_page.html:1:6891
Unknown property ‘font-smoothing’. Declaration dropped. _generated_background_page.html:1:26667
Error in parsing value for ‘animation’. Declaration dropped. _generated_background_page.html:1:27846
Ruleset ignored due to bad selector. _generated_background_page.html:1:14
Ruleset ignored due to bad selector. _generated_background_page.html:1:132
Ruleset ignored due to bad selector. _generated_background_page.html:1:13
Ruleset ignored due to bad selector. _generated_background_page.html:1:17
Ruleset ignored due to bad selector. _generated_background_page.html:1:16
Ruleset ignored due to bad selector. _generated_background_page.html:1:40
Ruleset ignored due to bad selector. 2 _generated_background_page.html:1:13
Ruleset ignored due to bad selector. _generated_background_page.html:1:40
Ruleset ignored due to bad selector. 4 _generated_background_page.html:1:13
Ruleset ignored due to bad selector. _generated_background_page.html:1:40
Ruleset ignored due to bad selector. 17 _generated_background_page.html:1:13
Ruleset ignored due to bad selector. _generated_background_page.html:1:40
Ruleset ignored due to bad selector. 13 _generated_background_page.html:1:13
Ruleset ignored due to bad selector. _generated_background_page.html:1:26
Ruleset ignored due to bad selector. _generated_background_page.html:1:71
Ruleset ignored due to bad selector. _generated_background_page.html:1:13
Ruleset ignored due to bad selector. _generated_background_page.html:1:132
Ruleset ignored due to bad selector. _generated_background_page.html:1:40
Ruleset ignored due to bad selector. _generated_background_page.html:1:25
Ruleset ignored due to bad selector. _generated_background_page.html:1:12
Ruleset ignored due to bad selector. _generated_background_page.html:1:19
Ruleset ignored due to bad selector. _generated_background_page.html:1:40
Ruleset ignored due to bad selector. _generated_background_page.html:1:25
Ruleset ignored due to bad selector. _generated_background_page.html:1:18
Ruleset ignored due to bad selector. _generated_background_page.html:1:13
Ruleset ignored due to bad selector. _generated_background_page.html:1:132
Ruleset ignored due to bad selector. _generated_background_page.html:1:12
Ruleset ignored due to bad selector. _generated_background_page.html:1:139
Ruleset ignored due to bad selector. _generated_background_page.html:1:23
Ruleset ignored due to bad selector. _generated_background_page.html:1:18
Ruleset ignored due to bad selector. _generated_background_page.html:1:40
Ruleset ignored due to bad selector. _generated_background_page.html:1:21
Ruleset ignored due to bad selector. _generated_background_page.html:1:12
Ruleset ignored due to bad selector. _generated_background_page.html:1:139
Ruleset ignored due to bad selector. _generated_background_page.html:1:23
Ruleset ignored due to bad selector. _generated_background_page.html:1:18
Ruleset ignored due to bad selector. _generated_background_page.html:1:40
Ruleset ignored due to bad selector. _generated_background_page.html:1:21
Ruleset ignored due to bad selector. _generated_background_page.html:1:12
Ruleset ignored due to bad selector. _generated_background_page.html:1:139
Ruleset ignored due to bad selector. _generated_background_page.html:1:23
Ruleset ignored due to bad selector. _generated_background_page.html:1:18
Ruleset ignored due to bad selector. _generated_background_page.html:1:40
Ruleset ignored due to bad selector. _generated_background_page.html:1:21
Ruleset ignored due to bad selector. _generated_background_page.html:1:12
Ruleset ignored due to bad selector. _generated_background_page.html:1:139
Ruleset ignored due to bad selector. _generated_background_page.html:1:23
Ruleset ignored due to bad selector. _generated_background_page.html:1:18
Ruleset ignored due to bad selector. _generated_background_page.html:1:40
Ruleset ignored due to bad selector. _generated_background_page.html:1:21
Ruleset ignored due to bad selector. _generated_background_page.html:1:12
Ruleset ignored due to bad selector. _generated_background_page.html:1:139
Ruleset ignored due to bad selector. _generated_background_page.html:1:23
Ruleset ignored due to bad selector. _generated_background_page.html:1:18
Ruleset ignored due to bad selector. _generated_background_page.html:1:40
Ruleset ignored due to bad selector. _generated_background_page.html:1:21
Ruleset ignored due to bad selector. _generated_background_page.html:1:12
Ruleset ignored due to bad selector. _generated_background_page.html:1:139
Ruleset ignored due to bad selector. _generated_background_page.html:1:23
Ruleset ignored due to bad selector. _generated_background_page.html:1:18
Ruleset ignored due to bad selector. _generated_background_page.html:1:40

@ThomazPom
Copy link
Owner

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ImageEditionBug Something isn't working with highly experimental ImageEdition feature
Projects
Status: In Progress
Development

No branches or pull requests

2 participants