Redirector icon indicating copy to clipboard operation
Redirector copied to clipboard

Redirector hangs whole browser after visiting some web-sites

Open AlexCzar opened this issue 2 years ago • 11 comments

After I visit Gmail, Amazon or some other heavy sites, Redirector will hang the whole UI, some resources will stop loading. Browser: Firefox 96.0.3 (64-bit) OS: Linux DE: KDE Plasma Maybe relevant extensions:

  • TreeStyleTab
  • Sidebery (subjectively, the issue is worse when this one is enabled vs when TST is enabled)
Configured redirects
{
    "createdBy": "Redirector v3.5.3",
    "createdAt": "2022-02-07T07:43:08.630Z",
    "redirects": [
        {
            "description": "Medium -> Scribe",
            "exampleUrl": "https://medium.com/@user/post-123456abcdef",
            "exampleResult": "https://scribe.rip//@user/post-123456abcdef",
            "error": null,
            "includePattern": "^https?://(?:.*\\.)*(?<!(link\\.|cdn\\-images\\-\\d+\\.))medium\\.com(/.*)?$",
            "excludePattern": "",
            "patternDesc": "",
            "redirectUrl": "https://scribe.rip/$2",
            "patternType": "R",
            "processMatches": "noProcessing",
            "disabled": false,
            "grouped": false,
            "appliesTo": [
                "main_frame",
                "sub_frame",
                "xmlhttprequest",
                "history",
                "other"
            ]
        },
        {
            "description": "Reddit -> Libreddit",
            "exampleUrl": "https://www.reddit.com/r/subreddit",
            "exampleResult": "https://r.nf//r/subreddit",
            "error": null,
            "includePattern": "^https?://(?:.*\\.)*reddit\\.com(/.*)?$",
            "excludePattern": "",
            "patternDesc": "",
            "redirectUrl": "https://r.nf/$1",
            "patternType": "R",
            "processMatches": "noProcessing",
            "disabled": false,
            "grouped": false,
            "appliesTo": [
                "main_frame"
            ]
        }
    ]
}

AlexCzar avatar Feb 07 '22 07:02 AlexCzar

I have the same issue with amazon. when I add stuff to the cart then clicking on the checkout button the extension consumes 100% CPU

{
    "createdBy": "Redirector v3.5.3",
    "createdAt": "2022-03-01T12:38:45.394Z",
    "redirects": [
        {
            "description": "Medium -> Scribe",
            "exampleUrl": "https://medium.com/@user/post-123456abcdef",
            "exampleResult": "https://scribe.rip//@user/post-123456abcdef",
            "error": null,
            "includePattern": "^https?://(?:.*\\.)*(?<!(link\\.|cdn\\-images\\-\\d+\\.))medium\\.com(/.*)?$",
            "excludePattern": "",
            "patternDesc": "",
            "redirectUrl": "https://scribe.rip/$2",
            "patternType": "R",
            "processMatches": "noProcessing",
            "disabled": false,
            "grouped": false,
            "appliesTo": [
                "main_frame"
            ]
        }
    ]
}

Crackz avatar Mar 01 '22 12:03 Crackz

I have the same problem but only since a few days ago... Using Chrome 99. The whole browser doesn't load any other webpage until I kill the addon. It's so bad that I had to disable it :/

Brawl345 avatar Mar 18 '22 19:03 Brawl345

Same problem on Edge. It would use 100% CPU all the time and prevent all pages to load, so also had to remove the extension.

I was also using the same Medium configuration as above and no Medium page was actually being displayed so the extension shouldn't have been doing anything.

laurent22 avatar May 31 '22 11:05 laurent22

@laurent22 In Redirector, did you only have the single redirect rule mentioned by "Crackz" (and originally posted by "AlexCzar") in this thread?

Also, had you visited any Medium pages within the prior 10 minutes before you experienced 100% CPU use?

Finally, so we have good records, on which version of Edge did you encounter this issue? Also, what other extensions, if any, did you have installed?

Gitoffthelawn avatar May 31 '22 23:05 Gitoffthelawn

I have other redirect rules added, but I tried disabling the above medium rule and the issue still pops up occasionally. I have a chromium-based browser v102.0.5005.125 I have multiple extensions, but I will try to disable some extensions at a time and observe again for the next few days. Is there a way to collect the log from the extension in a file?

Ok, so the errors file indicates this:

Error handling response: TypeError: Could not add listener
Context
_generated_background_page.html
Stack Trace
js/background.js:215 (anonymous function)

line 215: chrome.webNavigation.onHistoryStateUpdated.addListener(checkHistoryStateRedirects, filter);

decoherencer avatar Jun 19 '22 12:06 decoherencer

I too observe the problem.

Sometimes Redirector hangs browser and the only way to continue using it is either full restart or killing the extension

jtraub avatar Sep 19 '22 23:09 jtraub

Ok, I did some testing and narrowed down the problem.

The extension hangs when you visit a page with a very long URL with many dots in it (say, 500+ characters and 15+ dots).

UPD: Yeah, I noticed that I also have scribe.rip rule to redirect medium articles. I should have read the other comments more carefully instead of going blind and trying to locate the problem. I guess its regex is the reason.

jtraub avatar Sep 19 '22 23:09 jtraub

Scribe.rip rule is the culprit indeed.

It uses the following regex

^https?://(?:.*\.)*(?<!(link\.|cdn\-images\-\d+\.))medium\.com(/.*)?$

The regex has catastrophic backtracking.

This can be verified by opening browser console and putting

const regexp = new RegExp('^https?://(?:.*\.)*(?<!(link\.|cdn\-images\-\d+\.))medium\.com(/.*)?$');
regexp.exec('...put here a really long url or even just a string with 1500 chars and 20-40 dots ...')

there. You can now watch how the browser hangs.

Another way to verify is visiting this url with Redirector containing only mentioned scribe.rip rule. You can use this url in the console test too.

Switching to something like this should help

^https?://(?:[^\.]+\.){0,1}(?<!(link\.|cdn\-images\-\d+\.))medium\.com(/.*)?$

I guess I should report the issue to scribe.rip author.

jtraub avatar Sep 19 '22 23:09 jtraub

@jtraub Thanks for your posts. Very helpful. On which web browser (and version) did you experience this issue?

Gitoffthelawn avatar Sep 20 '22 03:09 Gitoffthelawn

@Gitoffthelawn

Chromium version 105.0.5195.125 (Official Build) Arch Linux (64-bit)

However, this problem will be observed on all browsers and all platforms as the number of steps during regex matching grows exponentially with the length of URL.

I am not sure Redirector can do anything here as the catastrophic backtracking can have so many forms and detecting it by searching patterns in regex is hard.

jtraub avatar Sep 20 '22 05:09 jtraub

@jtraub

I agree. The best solution may be to hope that someday web browsers will have JavaScript engines that can detect regex catastrophic backtracking and handle it gracefully. I'm not sure if any browsers do this already, but it sounds like we can probably rule out all Chromium-based browsers.

Gitoffthelawn avatar Sep 20 '22 11:09 Gitoffthelawn