Skip to content

Commit a9e7d46

Browse files
committed
See b/26741728. This fixes an issue reported by third party devs
in which the app sometimes crashes when locking/unlocking the device. Change-Id: I3ba4e6d77b79bec2db0e4417fb09794b6ff07645
1 parent 9cc4323 commit a9e7d46

File tree

1 file changed

+7
-1
lines changed
  • visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera

1 file changed

+7
-1
lines changed

visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSource.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,12 @@ void setNextFrame(byte[] data, Camera camera) {
861861
mPendingFrameData = null;
862862
}
863863

864+
if (!mBytesToByteBuffer.containsKey(data)) {
865+
Log.d(TAG, "Skipping frame. Could not find ByteBuffer associated with the " +
866+
"image data from the camera.");
867+
return;
868+
}
869+
864870
// Timestamp and frame ID are maintained here, which will give downstream code some
865871
// idea of the timing of frames received and when frames were dropped along the way.
866872
mPendingTimeMillis = SystemClock.elapsedRealtime() - mStartTimeMillis;
@@ -893,7 +899,7 @@ public void run() {
893899

894900
while (true) {
895901
synchronized (mLock) {
896-
if (mActive && (mPendingFrameData == null)) {
902+
while (mActive && (mPendingFrameData == null)) {
897903
try {
898904
// Wait for the next frame to be received from the camera, since we
899905
// don't have it yet.

0 commit comments

Comments
 (0)