question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Chromium] GM.xmlHttpRequest is very slow and buggy

See original GitHub issue

What is the problem?

GM.xmlHttpRequest is very slow and buggy.

How to reproduce it?

Use this script to download some file (30+MB) from a file hosting (sorry, no URL example, I will add it later (if you would still need))

// ==UserScript==
// @name        New script - GM.xmlHttpRequest
// @namespace   Violentmonkey Scripts
// @match       <PUT_HERE_THE_ADDRESS>   // TODO: add a demo URL
// @grant       GM.xmlHttpRequest
// @version     1.0
// @author      -
// @description GM.xmlHttpRequest slow chrome
// ==/UserScript==

const UNSENT           = 0;
const OPENED           = 1;
const HEADERS_RECEIVED = 2;
const LOADING          = 3;
const DONE             = 4;
const xml = GM.xmlHttpRequest({
  method: "GET",  
  url: "<PUT_HERE_THE_ADDRESS>",    // TODO: add a demo URL
  onload: function(response) {
    console.log("---onload---");
    console.log(response);
    console.log("response.loaded", response.loaded);
    console.log("response.responseText.length", response.responseText.length);
    console.log("response.response.length", response.response.length);
  },
  onreadystatechange: function(response) {
   console.log("onreadystatechange", response.readyState, response, response.responseText.length);
    if (response.readyState === HEADERS_RECEIVED) {
        console.log(response);
        console.log(response.responseHeaders);
    }
  },
});
console.log(xml);

What is the expected result?

GM.xmlHttpRequest works fast without freezing.

No problem in Firefox. And no problem with Tampermonkey (but it has no response.response and response.responseText === "" for onreadystatechange event) UPD: But it’s normal for using with `responseType: “arraybuffer”;

What is the actual result?

Downloading in the background script work absolutely OK (I checked it with DevTools). So it’s the problem with the sending data to the content script.

With little files ~5 MB it works ~OK. With files ~15 MB I works slow. For file 20 MB + it begins to work very slow, and probably freezing (no progress). Also the extension start to lag (Can’t immediately open the popup). Memory consuming is increasing.

Environment

  • Browser: Chrome, Opera.
  • Browser version: Chromium 85 based
  • Violentmonkey version: 2.12.7
  • OS: Win 10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tophfcommented, Oct 4, 2020

No, replacing doesn’t work in Chrome/Chromium because it performs automatic verification of file contents for extensions installed from the web store. Installing a separate unpacked extension is the proper method, it’s trivial and straightforward.

0reactions
AlttiRicommented, Oct 4, 2020

If the permissions were the same I could replace the extension’s files and have one extension with the same settings and auto-updating (when you finally release it). In comparison to installing RC as an additional unpacked extension.

Just a note.

UPD: In Chromium based browser, but not in Chrome. (as I said earlier)

Read more comments on GitHub >

github_iconTop Results From Across the Web

87772 - XMLHttpRequest crash due to running out of memory ...
It's indeed OOM in creating a Resource object. I ran the script locally. When I click 1000mb, Chrome crashed at WTF::partitionBucketFull(). It's limitation...
Read more >
XMLHttpRequest really slow on Google Chrome
I found it. It was just a caching issue. After clearing the cache in Firefox I got roughly the same loading time as...
Read more >
Untitled
Xiaoweixiao stream, How to slice a bone in ham shank, K project tales of black ... Exchange 2010 server very slow, Verdant brink...
Read more >
Tampermonkey • 3.0.3389 Changes
'DOM' access mode means that the script only needs DOM and no direct unsafeWindow access. If enabled these scripts are executed inside the...
Read more >
hwb - River Thames Conditions - Environment Agency - GOV.UK
Triljoen rand, Unique baby names that start with a, Project igi 3 mission 10! ... Xmlhttprequest withcredentials ie, Dama feat salvador cameira, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found