apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 987 forks source link

XMLHttpRequest memory leak #1311

Open kiture opened 1 year ago

kiture commented 1 year ago

Bug Report

Problem

After switch from version 4.5.5 to 6.2.0 there is a problem with XMLHttpRequest. In my app i'm downloading many files from server that are saved on device.

When i'm call this method many times likes ~400 (depends on device) on ~1MB file, the application crashes (before crash there is a warning about memory leak in Console app on Mac).

function load() {
    this._loader = new XMLHttpRequest();
    this._loader.open("GET", path, true);
    this._loader.onload = () => {
        if (this._loader.status != 200) {
            return;
        }
        load();
    };
    this._loader.responseType = "arraybuffer";
    this._loader.send();
}

This method just downloading file and does nothing with it (GC should just clean this).

This issue is similar to this one: https://github.com/apache/cordova-ios/issues/522

In version 4.5.5 all works fine, without any problem.

Environment, Platform, Device

iOS 15.7.3 (iPad mini 4) iOS (iphone 11)

Version information

cordova-cli 11.1.0 cordova-ios 6.2.0

Checklist

breautek commented 1 year ago

Are you using any xhr plugins?

XMLHttpRequest is handled by the webview implementation unless if you have a cordova plugin that overwrites it, which was a common solution people used to avoid CORS. The core cordova platform does not override XMLHttpRequest.

So if you're using an XHR plugin, that is likely the source. Otherwise the issue is likely within WKWebView itself.

kiture commented 1 year ago

I'm tested both versions, with and without plugin and there was the same result.