jsPlumb_Liviz.js icon indicating copy to clipboard operation
jsPlumb_Liviz.js copied to clipboard

"Failed to load blob" error in stopgo in Chrome 80/81

Open snowymike opened this issue 5 years ago • 0 comments

I don't expect a fix for this issue, as the library hasn't been updated in 6 years, but thought I'd report it, along with an apparent workaround, in case it is helpful to anyone else using this library.

Starting I believe with Chrome 80 or 81, the xhr.send in stopgo.js's compareFileContent started failing for me:

	function compareFileContent(url, keyword) {
		var xhr = new XMLHttpRequest();
		xhr.open('GET', url, false);
		xhr.send(null);

		return xhr.responseText.indexOf(keyword) >= 0;
	}

I'd see

"Uncaught DOMException: Failed to execute 'send' on 'XMLHTTPRequest': Failed to load 'blob:https://<host>:<port>/<blobid>'

I initially assumed this was due to changes with synchronous XHR handling in Chrome 80 (https://developers.google.com/web/updates/2019/12/chrome-80-deps-rems), but the following code continues to work in Chrome

var blob = new Blob(['RUN '], {type: 'text/plain'});
var url = URL.createObjectURL(blob);
var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
xhr.send(null);

Interestingly, Incognito mode in Chrome, as well as guest mode, continue to work. In Chromium Edge, it's the same - regular mode fails, InPrivate succeeds. The latest Firefox 75 and IE 11 work fine.

compareFileContent it turns out is only called if window.webkitRequestFileSystem is defined, which it only is on Chrome/Chromium. Here's some info on that API, along with warnings against using it - https://developer.mozilla.org/en-US/docs/Web/API/Window/requestFileSystem

Since this jsPlumb_Liviz.js library works fine for me in Firefox and IE 11, I tried simplifying createSharedFile to just be the code that runs, and works, in Firefox and IE 11. That is,

		createSharedFile: function(onComplete) {
			var _this = this;
			this.sharedFileWriter = this.sharedFileURL = null;
			onComplete(null);
			return;
		}

With this code change, we never get into compareFileContent() at all, and if there's a negative impact to functionality, I haven't found it yet.

I'm left wondering what purpose any of the window.webkitRequestFileSystem code served and why it existed if it wasn't needed. Neither the "RUN " nor "STOP" blobs are used when window.webkitRequestFileSystem is not defined. Maybe initially this code only worked in Chrome, and new browser functionality since then allowed it to work in multiple browsers and no longer required the Chrome specific handling. No idea.

Something else I noticed is that in IE 11, Firefox 57, and Chromium 81, MozBlobBuilder and WebKitBlobBuilder are not defined, so all blob construction just uses the native Blob constructor.

As I've stated, not expecting a fix to be released for this, but in case anyone else is struggling to figure out why this library no longer works in Chrome, give the createSharedFile code change a try.

snowymike avatar Apr 26 '20 11:04 snowymike