File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -315,7 +315,7 @@ export class BrowserCodeReader {
315
315
public static createCanvasFromMediaElement ( mediaElement : HTMLVisualMediaElement ) {
316
316
317
317
const canvas = BrowserCodeReader . createCaptureCanvas ( mediaElement ) ;
318
- const ctx = canvas . getContext ( '2d' , { willReadFrequently : true } ) ;
318
+ const ctx = canvas . getContext ( '2d' ) ;
319
319
320
320
if ( ! ctx ) {
321
321
throw new Error ( 'Couldn\'t find Canvas 2D Context.' ) ;
@@ -1032,8 +1032,13 @@ export class BrowserCodeReader {
1032
1032
/**
1033
1033
* The HTML canvas element context.
1034
1034
*/
1035
- let captureCanvasContext = captureCanvas . getContext ( '2d' ) ;
1036
-
1035
+ let captureCanvasContext ;
1036
+ try {
1037
+ captureCanvasContext = elem . getContext ( '2d' , { willReadFrequently : true } ) as CanvasRenderingContext2D ;
1038
+ } catch ( e ) {
1039
+ captureCanvasContext = elem . getContext ( '2d' ) ;
1040
+ }
1041
+
1037
1042
// cannot proceed w/o this
1038
1043
if ( ! captureCanvasContext ) {
1039
1044
throw new Error ( 'Couldn\'t create canvas for visual element scan.' ) ;
You can’t perform that action at this time.
0 commit comments