jenkins-bot has submitted this change and it was merged.

Change subject: mw.UploadWizardUpload: Improve error handling in #makePreview
......................................................................


mw.UploadWizardUpload: Improve error handling in #makePreview

* If we fail to load a video thumbnail within 10 seconds, give up.
* Workaround for NS_ERROR_NOT_AVAILABLE exceptions on Firefox.

Bug: T136831
Change-Id: I1fbff350bb289de4bf799d6324569c47ba0ea7d9
---
M resources/mw.UploadWizardUpload.js
1 file changed, 20 insertions(+), 2 deletions(-)

Approvals:
  MarkTraceur: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/resources/mw.UploadWizardUpload.js 
b/resources/mw.UploadWizardUpload.js
index 315c0c9..ef8c91d 100644
--- a/resources/mw.UploadWizardUpload.js
+++ b/resources/mw.UploadWizardUpload.js
@@ -1149,14 +1149,32 @@
                                                        canvas.width = 100;
                                                        canvas.height = 
Math.round( canvas.width * video.videoHeight / video.videoWidth );
                                                        context = 
canvas.getContext( '2d' );
-                                                       context.drawImage( 
video, 0, 0, canvas.width, canvas.height );
-                                                       upload.loadImage( 
canvas.toDataURL(), deferred );
+                                                       try {
+                                                               
context.drawImage( video, 0, 0, canvas.width, canvas.height );
+                                                               
upload.loadImage( canvas.toDataURL(), deferred );
+                                                       } catch ( err ) {
+                                                               if ( err.name 
=== 'NS_ERROR_NOT_AVAILABLE' ) {
+                                                                       // 
(T136831) Firefox doesn't like it when we draw many <video>s to <canvas> in
+                                                                       // 
quick succession. This seems to mostly happen when impatient users proceed to
+                                                                       // 
"deed" step before all thumbnails are loaded in "upload" step. Just ignore it
+                                                                       // and 
render a "broken" thumbnail.
+                                                                       
deferred.reject();
+                                                               } else {
+                                                                       throw 
err;
+                                                               }
+                                                       }
                                                        
upload.URL().revokeObjectURL( video.url );
                                                }, 500 );
                                        }
                                } );
                                url = this.URL().createObjectURL( this.file );
                                video.src = url;
+                               // If we can't get a frame within 10 seconds, 
something is probably seriously wrong.
+                               // This can happen for broken files where we 
can't actually seek to the time we wanted.
+                               setTimeout( function () {
+                                       deferred.reject();
+                                       upload.URL().revokeObjectURL( video.url 
);
+                               }, 10000 );
                        } else {
                                dataUrlReader = new FileReader();
                                dataUrlReader.onload = function () {

-- 
To view, visit https://gerrit.wikimedia.org/r/299902
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1fbff350bb289de4bf799d6324569c47ba0ea7d9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz DziewoƄski <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to