[Chromium] GM.xmlHttpRequest is very slow and buggy
See original GitHub issueWhat 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:
- Created 3 years ago
- Comments:12 (4 by maintainers)

Top Related StackOverflow Question
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.
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)