bitpay / cordova-plugin-qrscanner

A fast, energy efficient, highly-configurable QR code scanner for Cordova apps and the browser.
MIT License
567 stars 773 forks source link

Android Black Screen on scan when reopen the app #368

Open xusimr97 opened 2 years ago

xusimr97 commented 2 years ago

The first time i open the app all works fine, i can scan multiple times, but if i close the app and then open it, the camera turns on but doesn't appear the video.

If i clear cache and try it occurs the same, the first init of app goes well but the second no.

This is my log: 2022-02-23 12:43:42.968 2487-2487/servinform.emuca.app I/AssistStructure: Flattened final assist data: 2236 bytes, containing 1 windows, 4 views 2022-02-23 12:43:42.971 2487-2487/servinform.emuca.app I/AssistStructure: Flattened final assist data: 2236 bytes, containing 1 windows, 4 views 2022-02-23 12:43:43.132 2487-2582/servinform.emuca.app D/SERVER: Handling local request: http://localhost/assets/icon/favicon.png 2022-02-23 12:43:43.935 2487-2487/servinform.emuca.app D/ForceDarkHelper: updateByCheckExcludeList: pkg: servinform.emuca.app activity: servinform.emuca.app.MainActivity@926525c 2022-02-23 12:43:43.937 2487-2487/servinform.emuca.app D/ForceDarkHelper: updateByCheckExcludeList: pkg: servinform.emuca.app activity: servinform.emuca.app.MainActivity@926525c 2022-02-23 12:43:43.937 2487-2487/servinform.emuca.app D/CameraPreview: resume() 2022-02-23 12:43:43.940 2487-4299/servinform.emuca.app D/CameraInstance: Opening camera 2022-02-23 12:43:43.930 2487-2487/servinform.emuca.app W/CameraThread: type=1400 audit(0.0:2780468): avc: denied { read } for name="u:object_r:vendor_default_prop:s0" dev="tmpfs" ino=20237 scontext=u:r:untrusted_app:s0:c28,c258,c512,c768 tcontext=u:object_r:vendor_default_prop:s0 tclass=file permissive=0 2022-02-23 12:43:43.941 2487-4299/servinform.emuca.app E/libc: Access denied finding property "vendor.camera.hal1.packagelist" 2022-02-23 12:43:43.977 2487-4299/servinform.emuca.app D/CameraInstance: Configuring camera 2022-02-23 12:43:43.977 2487-4299/servinform.emuca.app I/CameraManager: Camera Display Orientation: 90 2022-02-23 12:43:43.979 2487-4299/servinform.emuca.app I/CameraManager: Initial camera parameters: preview-size=1920x1080;video-size=1920x1080;preferred-preview-size-for-video=1920x1080;preview-size-values=1920x1440,1920x1080,1600x1200,1440x1080,1280x960,1560x720,1440x720,1280x720,800x600,720x480,640x480,640x360,352x288,320x240,176x144;video-size-values=3840x2160,2688x1512,2592x1940,2592x1196,1920x1440,2340x1080,2160x1080,1920x1080,1600x1200,1440x1080,1280x960,1560x720,1440x720,1280x720,800x600,720x480,640x480,640x360,352x288,320x240,176x144;preview-format=yuv420sp;preview-format-values=yuv420p,yuv420sp,;preview-frame-rate=30;preview-fps-range=8000,30000;preview-fps-range-values=(4000,15000),(15000,15000),(8000,30000),(30000,30000);preview-frame-rate-values=15,30;picture-size=4000x3000;picture-size-values=4000x3000,4000x2250,3840x2160,3264x2448,3000x3000,2688x1512,2592x1940,2592x1196,2448x2448,1920x1440,2340x1080,2160x1080,1920x1080,1600x1200,1440x1080,1280x960,1560x720,1440x720,1280x720,800x600,720x480,640x480,640x360,352x288,320x240,176x144;picture-format=jpeg;picture-format-values=jpeg;jpeg-thumbnail-width=320;jpeg-thumbnail-height=240;jpeg-thumbnail-size-values=0x0,176x144,240x144,256x144,240x160,256x154,246x184,240x240,320x240;jpeg-thumbnail-quality=90;jpeg-quality=90;rotation=0;whitebalance=auto;whitebalance-values=auto,incandescent,fluorescent,warm-fluorescent,daylight,cloudy-daylight,twilight,shade,;effect=none;effect-values=none,mono,negative,solarize,sepia,posterize,aqua,blackboard,whiteboard;antibanding=auto;antibanding-values=off,50hz,60hz,auto;flash-mode=off;flash-mode-values=off,auto,on,torch,red-eye;focus-mode=auto;focus-mode-values=infinity,auto,macro,continuous-video,continuous-picture;max-num-focus-areas=1;focus-areas=(0,0,0,0,0);focal-length=4.77;horizontal-view-angle=67.7121;vertical-view-angle=53.418;exposure-compensation=0;max-exposure-compensation=12;min-exposure-compensation=-12;exposure-compensation-step=0.166667;auto-exposure-lock=false;auto-exposure-lock-supported=true;auto-whitebalance-lock=false;auto-whitebalance-lock-supported=true;max-num-metering-areas=1;metering-areas=(0,0,0,0,0);zoom=0;max-zoom=99;zoom-ratios=100,109,118,127,136,145,154,163,172,181,190,200,209,218,227,236,245,254,263,272,281,290,299,309,318,327,336,345,354,363,372,381,390,399,409,418,427,436,445,454,463,472,481,490,499,509,518,527,536,545,554,563,572,581,590,599,609,618,627,636,645,654,663,672,681,690,699,709,718,727,736,745,754,763,772,781,790,799,809,818,827,836,845,854,863,872,881,890,899,909,918,927,936,945,954,963,972,981,990,999;zoom-supported=true;smooth-zoom-supported=false;focus-distances=Infinity,Infinity,Infinity;max-num-detected-faces-hw=10;max-num-detected-faces-sw=0;video-frame-format=android-opaque;recording-hint=false;video-snapshot-supported=true;video-stabilization=false;video-stabilization-supported=true 2022-02-23 12:43:43.979 2487-4299/servinform.emuca.app I/CameraConfiguration: Requesting focus mode value from among: [auto] 2022-02-23 12:43:43.979 2487-4299/servinform.emuca.app I/CameraConfiguration: Supported focus mode values: [infinity, auto, macro, continuous-video, continuous-picture] 2022-02-23 12:43:43.980 2487-4299/servinform.emuca.app I/CameraConfiguration: Can set focus mode to: auto 2022-02-23 12:43:43.980 2487-4299/servinform.emuca.app I/CameraConfiguration: Focus mode already set to auto 2022-02-23 12:43:43.980 2487-4299/servinform.emuca.app I/CameraConfiguration: Requesting flash mode value from among: [off] 2022-02-23 12:43:43.980 2487-4299/servinform.emuca.app I/CameraConfiguration: Supported flash mode values: [off, auto, on, torch, red-eye] 2022-02-23 12:43:43.980 2487-4299/servinform.emuca.app I/CameraConfiguration: Can set flash mode to: off 2022-02-23 12:43:43.980 2487-4299/servinform.emuca.app I/CameraConfiguration: Flash mode already set to off 2022-02-23 12:43:43.981 2487-4299/servinform.emuca.app I/PreviewScalingStrategy: Viewfinder size: 1418x1080 2022-02-23 12:43:43.981 2487-4299/servinform.emuca.app I/PreviewScalingStrategy: Preview in order of preference: [1440x1080, 1600x1200, 1280x960, 1920x1440, 1920x1080, 800x600, 1280x720, 640x480, 1440x720, 1560x720, 720x480, 640x360, 352x288, 320x240, 176x144] 2022-02-23 12:43:43.982 2487-4299/servinform.emuca.app I/CameraManager: Final camera parameters: video-size=1920x1080;preferred-preview-size-for-video=1920x1080;preview-size-values=1920x1440,1920x1080,1600x1200,1440x1080,1280x960,1560x720,1440x720,1280x720,800x600,720x480,640x480,640x360,352x288,320x240,176x144;video-size-values=3840x2160,2688x1512,2592x1940,2592x1196,1920x1440,2340x1080,2160x1080,1920x1080,1600x1200,1440x1080,1280x960,1560x720,1440x720,1280x720,800x600,720x480,640x480,640x360,352x288,320x240,176x144;preview-format=yuv420sp;preview-format-values=yuv420p,yuv420sp,;preview-frame-rate=30;preview-fps-range=8000,30000;preview-fps-range-values=(4000,15000),(15000,15000),(8000,30000),(30000,30000);preview-frame-rate-values=15,30;picture-size=4000x3000;picture-size-values=4000x3000,4000x2250,3840x2160,3264x2448,3000x3000,2688x1512,2592x1940,2592x1196,2448x2448,1920x1440,2340x1080,2160x1080,1920x1080,1600x1200,1440x1080,1280x960,1560x720,1440x720,1280x720,800x600,720x480,640x480,640x360,352x288,320x240,176x144;picture-format=jpeg;picture-format-values=jpeg;jpeg-thumbnail-width=320;jpeg-thumbnail-height=240;jpeg-thumbnail-size-values=0x0,176x144,240x144,256x144,240x160,256x154,246x184,240x240,320x240;jpeg-thumbnail-quality=90;jpeg-quality=90;rotation=0;whitebalance=auto;whitebalance-values=auto,incandescent,fluorescent,warm-fluorescent,daylight,cloudy-daylight,twilight,shade,;effect=none;effect-values=none,mono,negative,solarize,sepia,posterize,aqua,blackboard,whiteboard;antibanding=auto;antibanding-values=off,50hz,60hz,auto;flash-mode=off;flash-mode-values=off,auto,on,torch,red-eye;focus-mode=auto;focus-mode-values=infinity,auto,macro,continuous-video,continuous-picture;max-num-focus-areas=1;focus-areas=(0,0,0,0,0);focal-length=4.77;horizontal-view-angle=67.7121;vertical-view-angle=53.418;exposure-compensation=0;max-exposure-compensation=12;min-exposure-compensation=-12;exposure-compensation-step=0.166667;auto-exposure-lock=false;auto-exposure-lock-supported=true;auto-whitebalance-lock=false;auto-whitebalance-lock-supported=true;max-num-metering-areas=1;metering-areas=(0,0,0,0,0);zoom=0;max-zoom=99;zoom-ratios=100,109,118,127,136,145,154,163,172,181,190,200,209,218,227,236,245,254,263,272,281,290,299,309,318,327,336,345,354,363,372,381,390,399,409,418,427,436,445,454,463,472,481,490,499,509,518,527,536,545,554,563,572,581,590,599,609,618,627,636,645,654,663,672,681,690,699,709,718,727,736,745,754,763,772,781,790,799,809,818,827,836,845,854,863,872,881,890,899,909,918,927,936,945,954,963,972,981,990,999;zoom-supported=true;smooth-zoom-supported=false;focus-distances=Infinity,Infinity,Infinity;max-num-detected-faces-hw=10;max-num-detected-faces-sw=0;video-frame-format=android-opaque;recording-hint=false;video-snapshot-supported=true;video-stabilization=false;video-stabilization-supported=true;preview-size=1440x1080 2022-02-23 12:43:44.006 2487-2487/servinform.emuca.app I/CenterCropStrategy: Preview: 1080x1440; Scaled: 1080x1440; Want: 1080x1418 2022-02-23 12:43:44.007 2487-2487/servinform.emuca.app I/CameraPreview: Starting preview 2022-02-23 12:43:44.007 2487-4299/servinform.emuca.app D/CameraInstance: Starting preview 2022-02-23 12:43:44.014 2487-2582/servinform.emuca.app D/SERVER: Handling local request: http://localhost/assets/icon/favicon.png 2022-02-23 12:43:44.028 2487-2487/servinform.emuca.app I/chromium: [INFO:CONSOLE(1319)] "[object Object]", source: http://localhost/main-es2015.js (1319) 2022-02-23 12:43:44.046 2487-2487/servinform.emuca.app I/chromium: [INFO:CONSOLE(1360)] "[object Object]", source: http://localhost/main-es2015.js (1360) 2022-02-23 12:43:44.140 2487-4299/servinform.emuca.app I/AutoFocusManager: Current focus mode 'auto'; use auto focus? true 2022-02-23 12:43:44.533 2487-4299/servinform.emuca.app W/BpBinder: Slow Binder: BpBinder transact took 391 ms, interface=android.hardware.ICamera, code=3 oneway=false

Screenshot_20220223_124154 Screenshot_20220223_124231

v1934 commented 2 years ago

This is an issue I noticed on Android 11/12 on some devices. The methods show and hide work in reverse - you can check it out by launching the app in debug mode and inspecting it. Execute QRScanner.hide() and you will see the camera, whereas QRScanner.show() will hide it. It's embarassing that this is the only plugin for scannign QR Codes in cordova and it's full of flaws and bugs that haven't been fixed for ages.

v1934 commented 2 years ago

I seem to have fixed the issue, at least on my side (tested on Android 7 up to 12. iOS not affected at all). The background colors were messed up because of some old Android bug and the creator tried making a workaround by setting alpha to 1 (although I don't know what's the idea of setting TRANSPARENT under hide()... should be just black). I have forked the plugin and re-published the built version to NPM since it is required to properly install the plugin: https://github.com/v1934/cordova-plugin-qrscanner-11

You can try by just installing it with version 3.0.2 instead of this one like you would normally, just change the name to cordova-plugin-qrscanner-11

There was another plugin with added barcode support and this bug "fixed" (although still wrong, webview stayed transparent all the time) called cordova-plugin-qrscanner-codaxy but it cannot even be installed properly because dude hasn't published the build to npm afaik and it's missing webpack compiled files

Not even making any PR because this repo is abandoned for years already

pvkrijesh commented 1 year ago

even I am facing the same issue but for me it scan but not shown the camera and getting a black screen. tired of setting up background : transparent , opacity : 0 , z-index etc... but no luck .. if any one can give an exact solution then it would be much appreciated.