cordova-ios icon indicating copy to clipboard operation
cordova-ios copied to clipboard

XMLHttpRequest memory leak

Open kiture opened this issue 2 years ago • 2 comments

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

  • [x ] I searched for existing GitHub issues
  • [x ] I updated all Cordova tooling to most recent version
  • [x ] I included all the necessary information above

kiture avatar Apr 15 '23 11:04 kiture

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.

breautek avatar Apr 18 '23 16:04 breautek

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

kiture avatar Apr 18 '23 19:04 kiture