Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Merge pull request #318 from vladimir-kotikov/surface3_crash
Browse files Browse the repository at this point in the history
Avoid crash on Surface3
  • Loading branch information
macdonst authored Sep 8, 2016
2 parents 31d9bad + 1473daa commit 4fffc8d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/windows/BarcodeScannerProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,14 @@ module.exports = {
}

// Multiple calls to focusAsync leads to internal focusing hang on some Windows Phone 8.1 devices
if (controller.focusControl.focusState === Windows.Media.Devices.MediaCaptureFocusState.searching) {
return result;
// Also need to wrap in try/catch to avoid crash on Surface 3 - looks like focusState property
// somehow is not accessible there. See https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/288
try {
if (controller.focusControl.focusState === Windows.Media.Devices.MediaCaptureFocusState.searching) {
return result;
}
} catch (e) {
// Nothing to do - just continue w/ focusing
}

// The delay prevents focus hang on slow devices
Expand Down Expand Up @@ -399,7 +405,7 @@ module.exports = {

focusControl.configure(focusConfig);

// Continuous focus should start only after preview has started. See 'Remarks' at
// Continuous focus should start only after preview has started. See 'Remarks' at
// https://msdn.microsoft.com/en-us/library/windows/apps/windows.media.devices.focuscontrol.configure.aspx
function waitForIsPlaying() {
var isPlaying = !capturePreview.paused && !capturePreview.ended && capturePreview.readyState > 2;
Expand Down

0 comments on commit 4fffc8d

Please sign in to comment.