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

Slow and abnormally lagging GM.xmlHttpRequest #1107

Closed
AlttiRi opened this issue Dec 27, 2020 · 3 comments
Closed

Slow and abnormally lagging GM.xmlHttpRequest #1107

AlttiRi opened this issue Dec 27, 2020 · 3 comments
Labels
Milestone

Comments

@AlttiRi
Copy link

AlttiRi commented Dec 27, 2020

I have noted about this in this comment, but I think it's better to create a separate issue.
Also the similar behaviour was in VM, but it was fixed recently.

Expected Behavior

Downloading with GM.xmlHttpRequest of "big" files works fast, without any lag or freezing.
ViolentMonkey (the latest version) downloads a 100 MB almost instantly (as soon as all data were received from a server).

Actual Behavior

Downloading of a 100 MB file leads to a lags for 6 second + for 10 the page is totally frozen. (16 seconds of total)

Specifications

  • Chromium: 85
  • TM: 4.12.6123 (Beta)
  • OS: Win10

Script

// ==UserScript==
// @name        Issue 1107 (GM.xmlHttpRequest, 104 MB, gfycat.com)
// @namespace   Issues
// @match       https://github.com/Tampermonkey/tampermonkey/issues/1107
// @match       https://example.com/
// @grant       GM.xmlHttpRequest
// @connect     giant.gfycat.com
// ==/UserScript==

!async function() {
    console.log("downloading (104 MB)...");
    const response = await new Promise((resolve, reject) => {
        GM.xmlHttpRequest({
            method: "get",
            url: "https://giant.gfycat.com/ConfusedRecentGuppy.mp4", // 104 MB
            responseType: "blob",
            onload: resolve,
            onerror: reject,
        });
    });
    console.log("response:", response);

    const {response: blob} = response;
    downloadBlob(blob, "ConfusedRecentGuppy.mp4");
}();

function downloadBlob(blob, name) {
    const anchor = document.createElement("a");
    anchor.setAttribute("download", name || "");
    anchor.href = URL.createObjectURL(blob);
    anchor.click();
}
@AlttiRi
Copy link
Author

AlttiRi commented Dec 27, 2020

Install this script, reload this page, and try to select different parts of a text, you will see the lags (~1 fps) and the page freezing for some time until the file is downloaded (saved).
You can also try this with less sized file (32 MB): https://giant.gfycat.com/ShockedSecondaryFiddlercrab.mp4


Note: the lags (freezing) start after the file downloading was complied in the background script (when the data transmit will be started from the background script to the content script).

@derjanb derjanb added the bug label Dec 30, 2020
@derjanb derjanb added this to the 4.12 milestone Dec 30, 2020
@derjanb
Copy link
Member

derjanb commented Dec 30, 2020

Duplicate of #279

Please see #279 (comment) for more information.

@derjanb derjanb closed this as completed Dec 30, 2020
@AlttiRi
Copy link
Author

AlttiRi commented Dec 31, 2020

The script does not work at all with 4.12.6124. File is not saved.

UPD: only on github.com due to CSP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants