zxing-android-embedded icon indicating copy to clipboard operation
zxing-android-embedded copied to clipboard

Activity is destroyed after calling the library

Open kore01 opened this issue 5 years ago • 5 comments

Description of the problem:

After I call the library in my activity it is destroyed. I tried opening a new activity and calling the library there and there was no problem. The first one has a fragment in it and it is connected to 2 menus but those are all the differences.

Which library version are you using? 3.2.0

Which phone/tablet are you using, and which Android version does it run? Samsung Galaxy A40, Android 9.0

Does the same happen on other devices or an emulator? Yeap, tried it on a Pixel XL with Android 24.0

Can you reproduce the issue in the sample project included with the library? If not, can you provide your own sample project or sample code that produces this error? It is in the EcoVitae project on my profile (the first uploaded version)

In the case of an error do you have a stack trace or adb logs? 2020-02-09 15:40:41.663 734-734/com.appp.ecovitae D/ViewRootImpl@e9ef8b8[Main2Activity]: MSG_WINDOW_FOCUS_CHANGED 0 1 2020-02-09 15:40:41.663 734-734/com.appp.ecovitae D/InputMethodManager: prepareNavigationBarInfo() DecorView@acc3fd6[Main2Activity] 2020-02-09 15:40:41.663 734-734/com.appp.ecovitae D/InputMethodManager: getNavigationBarColor() -855310 2020-02-09 15:40:41.681 734-734/com.appp.ecovitae D/SurfaceView: onWindowVisibilityChanged(0) true android.view.SurfaceView{f21a197 V.E...... ......I. 0,0-0,0} of ViewRootImpl@a66ddd8[CaptureActivity] 2020-02-09 15:40:41.707 734-734/com.appp.ecovitae D/ViewRootImpl@a66ddd8[CaptureActivity]: Relayout returned: old=[0,0][2196,1080] new=[86,0][2196,1080] result=0x7 surface={true 520934305792} changed=true 2020-02-09 15:40:41.713 734-916/com.appp.ecovitae D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000 2020-02-09 15:40:41.713 734-916/com.appp.ecovitae D/OpenGLRenderer: eglCreateWindowSurface = 0x7949321880, 0x794a1ab010 2020-02-09 15:40:41.732 734-734/com.appp.ecovitae D/SurfaceView: show() Surface(name=SurfaceView - com.appp.ecovitae/com.journeyapps.barcodescanner.CaptureActivity@f21a197@0[734])/@0x3314ba2 android.view.SurfaceView{f21a197 V.E...... ......ID 0,0-2110,1080} 2020-02-09 15:40:41.735 734-734/com.appp.ecovitae D/SurfaceView: surfaceCreated 1 #8 android.view.SurfaceView{f21a197 V.E...... ......ID 0,0-2110,1080} 2020-02-09 15:40:41.736 734-734/com.appp.ecovitae D/SurfaceView: surfaceChanged (2110,1080) 1 #8 android.view.SurfaceView{f21a197 V.E...... ......ID 0,0-2110,1080} 2020-02-09 15:40:41.783 734-734/com.appp.ecovitae D/ViewRootImpl@a66ddd8[CaptureActivity]: Relayout returned: old=[86,0][2196,1080] new=[86,0][2196,1080] result=0x3 surface={true 520934305792} changed=false 2020-02-09 15:40:41.815 734-734/com.appp.ecovitae D/ViewRootImpl@a66ddd8[CaptureActivity]: MSG_RESIZED_REPORT: frame=[86,0][2196,1080] ci=[0,0][0,0] vi=[0,0][0,0] or=2 2020-02-09 15:40:41.815 734-734/com.appp.ecovitae D/ViewRootImpl@a66ddd8[CaptureActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1 2020-02-09 15:40:41.827 734-734/com.appp.ecovitae D/InputMethodManager: prepareNavigationBarInfo() DecorView@8e10fd[CaptureActivity] 2020-02-09 15:40:41.827 734-734/com.appp.ecovitae D/InputMethodManager: getNavigationBarColor() -855310 2020-02-09 15:40:41.829 734-734/com.appp.ecovitae D/InputMethodManager: prepareNavigationBarInfo() DecorView@8e10fd[CaptureActivity] 2020-02-09 15:40:41.830 734-734/com.appp.ecovitae D/InputMethodManager: getNavigationBarColor() -855310 2020-02-09 15:40:41.830 734-734/com.appp.ecovitae V/InputMethodManager: Starting input: tba=com.appp.ecovitae ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false 2020-02-09 15:40:41.830 734-734/com.appp.ecovitae D/InputMethodManager: startInputInner - Id : 0 2020-02-09 15:40:41.831 734-734/com.appp.ecovitae I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus 2020-02-09 15:40:41.844 734-734/com.appp.ecovitae D/InputTransport: Input channel constructed: fd=95 2020-02-09 15:40:41.844 734-734/com.appp.ecovitae D/InputTransport: Input channel destroyed: fd=89 2020-02-09 15:40:41.876 734-916/com.appp.ecovitae W/libEGL: EGLNativeWindowType 0x794a424010 disconnect failed 2020-02-09 15:40:41.876 734-916/com.appp.ecovitae D/OpenGLRenderer: eglDestroySurface = 0x795faa8600, 0x794a424000 2020-02-09 15:40:42.007 734-734/com.appp.ecovitae D/ViewRootImpl@e9ef8b8[Main2Activity]: Relayout returned: old=[0,0][1080,2340] new=[0,0][1080,2340] result=0x5 surface={false 0} changed=true 2020-02-09 15:40:42.034 734-1074/com.appp.ecovitae D/CameraInstance: Configuring camera 2020-02-09 15:40:42.035 734-1074/com.appp.ecovitae I/CameraManager: Camera Display Orientation: 0 2020-02-09 15:40:42.040 734-734/com.appp.ecovitae D/ViewRootImpl@e9ef8b8[Main2Activity]: stopped(true) old=false 2020-02-09 15:40:42.041 734-1074/com.appp.ecovitae I/CameraManager: Initial camera parameters: preview-size=1920x1080;video-size=1920x1080;preferred-preview-size-for-video=1920x1080;preview-size-values=1920x1080,1440x1080,1280x720,1152x864,1088x1088,1056x704,1024x768,960x720,880x720,800x450,720x720,720x480,640x480,480x320,352x288,320x240,256x144,176x144;video-size-values=1920x1080,1440x1080,1280x720,1152x864,1056x704,1024x768,960x720,880x720,800x450,720x720,720x480,640x480,480x320,352x288,320x240,256x144,176x144;preview-format=yuv420sp;preview-format-values=yuv420p,yuv420sp;preview-frame-rate=30;preview-fps-range=7000,30000;preview-fps-range-values=(15000,15000),(10000,24000),(15000,24000),(24000,24000),(7000,30000),(8000,30000),(10000,30000),(15000,30000),(30000,30000);preview-frame-rate-values=15,24,30;picture-size=4608x3456;picture-size-values=4608x3456,4608x2592,4608x2128,3840x2160,3456x3456,2336x1080,1920x1080,1440x1080,1280x720,1088x1088,1056x704,1024x768,960x720,880x720,800x450,720x720,720x480,640x480,480x320,352x288,320x240;picture-format=jpeg;picture-format-values=jpeg;jpeg-thumbnail-width=512;jpeg-thumbnail-height=384;jpeg-thumbnail-size-values=0x0,512x236,384x384,512x288,512x384;jpeg-thumbnail-quality=90;jpeg-quality=90;rotation=0;whitebalance=auto;whitebalance-values=auto,incandescent,fluorescent,daylight,cloudy-daylight;effect=none;effect-values=none,mono,negative,sepia,posterize,aqua;antibanding=auto;antibanding-values=off,auto;scene-mode=auto;scene-mode-values=auto,;flash-mode=off;flash-mode-values=off,auto,on,torch;focus-mode=auto;focus-mode-values=infinity,auto,continuous-video,continuous-picture;max-num-focus-areas=1;focus-areas=(0,0,0,0,0);focal-length=3.92;horizontal-view-angle=66.7131;vertical-view-angle=52.5557;exposure-compensation=0;max-exposure-compensation=20;min-exposure-compensation=-20;exposure-compensation-step=0.1;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,103,106,109,112,115,118,121,124,127,130,133,136,139,142,145,148,151,154,157,160,163,166,169,172,175,178,181,184,187,190,193,196,199,203,206,209,212,215,218,221,224,227,230,233,236,239,242,245,248,251,254,257,260,263,266,269,272,275,278,281,284,287,290,293,296,299,303,306,309,312,315,318,321,324,327,330,333,336,339,342,345,348,351,354,357,360,363,366,369,372,375,378,381,384,387,390,393,396,399;zoom-supported=true;smooth-zoom-supported=false;focus-distances=Infinity,Infinity,Infinity;max-num-detected-faces-hw=16;max-num-detected-faces-sw=0;video-frame-format=android-opaque;recording-hint=false;video-stabilization=false;video-stabilization-supported=false;video-snapshot-supported=false 2020-02-09 15:40:42.043 734-1074/com.appp.ecovitae I/CameraConfiguration: Requesting focus mode value from among: [auto] 2020-02-09 15:40:42.043 734-1074/com.appp.ecovitae I/CameraConfiguration: Supported focus mode values: [infinity, auto, continuous-video, continuous-picture] 2020-02-09 15:40:42.044 734-1074/com.appp.ecovitae I/CameraConfiguration: Can set focus mode to: auto 2020-02-09 15:40:42.044 734-1074/com.appp.ecovitae I/CameraConfiguration: Focus mode already set to auto 2020-02-09 15:40:42.044 734-1074/com.appp.ecovitae I/CameraConfiguration: Requesting flash mode value from among: [off] 2020-02-09 15:40:42.044 734-1074/com.appp.ecovitae I/CameraConfiguration: Supported flash mode values: [off, auto, on, torch] 2020-02-09 15:40:42.044 734-1074/com.appp.ecovitae I/CameraConfiguration: Can set flash mode to: off 2020-02-09 15:40:42.044 734-1074/com.appp.ecovitae I/CameraConfiguration: Flash mode already set to off 2020-02-09 15:40:42.045 734-1074/com.appp.ecovitae I/PreviewScalingStrategy: Viewfinder size: 2110x1080 2020-02-09 15:40:42.045 734-1074/com.appp.ecovitae I/PreviewScalingStrategy: Preview in order of preference: [1920x1080, 1280x720, 1440x1080, 1056x704, 1152x864, 800x450, 1024x768, 960x720, 720x480, 880x720, 1088x1088, 640x480, 480x320, 720x720, 256x144, 320x240, 352x288, 176x144] 2020-02-09 15:40:42.046 734-1074/com.appp.ecovitae I/CameraManager: Final camera parameters: video-size=1920x1080;preferred-preview-size-for-video=1920x1080;preview-size-values=1920x1080,1440x1080,1280x720,1152x864,1088x1088,1056x704,1024x768,960x720,880x720,800x450,720x720,720x480,640x480,480x320,352x288,320x240,256x144,176x144;video-size-values=1920x1080,1440x1080,1280x720,1152x864,1056x704,1024x768,960x720,880x720,800x450,720x720,720x480,640x480,480x320,352x288,320x240,256x144,176x144;preview-format=yuv420sp;preview-format-values=yuv420p,yuv420sp;preview-frame-rate=30;preview-fps-range=7000,30000;preview-fps-range-values=(15000,15000),(10000,24000),(15000,24000),(24000,24000),(7000,30000),(8000,30000),(10000,30000),(15000,30000),(30000,30000);preview-frame-rate-values=15,24,30;picture-size=4608x3456;picture-size-values=4608x3456,4608x2592,4608x2128,3840x2160,3456x3456,2336x1080,1920x1080,1440x1080,1280x720,1088x1088,1056x704,1024x768,960x720,880x720,800x450,720x720,720x480,640x480,480x320,352x288,320x240;picture-format=jpeg;picture-format-values=jpeg;jpeg-thumbnail-width=512;jpeg-thumbnail-height=384;jpeg-thumbnail-size-values=0x0,512x236,384x384,512x288,512x384;jpeg-thumbnail-quality=90;jpeg-quality=90;rotation=0;whitebalance=auto;whitebalance-values=auto,incandescent,fluorescent,daylight,cloudy-daylight;effect=none;effect-values=none,mono,negative,sepia,posterize,aqua;antibanding=auto;antibanding-values=off,auto;scene-mode=auto;scene-mode-values=auto,;flash-mode=off;flash-mode-values=off,auto,on,torch;focus-mode=auto;focus-mode-values=infinity,auto,continuous-video,continuous-picture;max-num-focus-areas=1;focus-areas=(0,0,0,0,0);focal-length=3.92;horizontal-view-angle=66.7131;vertical-view-angle=52.5557;exposure-compensation=0;max-exposure-compensation=20;min-exposure-compensation=-20;exposure-compensation-step=0.1;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,103,106,109,112,115,118,121,124,127,130,133,136,139,142,145,148,151,154,157,160,163,166,169,172,175,178,181,184,187,190,193,196,199,203,206,209,212,215,218,221,224,227,230,233,236,239,242,245,248,251,254,257,260,263,266,269,272,275,278,281,284,287,290,293,296,299,303,306,309,312,315,318,321,324,327,330,333,336,339,342,345,348,351,354,357,360,363,366,369,372,375,378,381,384,387,390,393,396,399;zoom-supported=true;smooth-zoom-supported=false;focus-distances=Infinity,Infinity,Infinity;max-num-detected-faces-hw=16;max-num-detected-faces-sw=0;video-frame-format=android-opaque;recording-hint=false;video-stabilization=false;video-stabilization-supported=false;video-snapshot-supported=false;preview-size=1920x1080 2020-02-09 15:40:42.047 734-734/com.appp.ecovitae I/on stop: stoppp 2020-02-09 15:40:42.050 734-734/com.appp.ecovitae I/FragmentNavigator: Ignoring navigate() call: FragmentManager has already saved its state 2020-02-09 15:40:42.051 734-734/com.appp.ecovitae I/on save: save 2020-02-09 15:40:42.052 734-734/com.appp.ecovitae I/scannedResult: fdvadgtr 2020-02-09 15:40:42.065 734-734/com.appp.ecovitae I/scannedResult: fdvadgtr 2020-02-09 15:40:42.087 734-734/com.appp.ecovitae I/on destroy: destroyy 2020-02-09 15:40:42.088 734-734/com.appp.ecovitae I/FragmentNavigator: Ignoring navigate() call: FragmentManager has already saved its state 2020-02-09 15:40:42.097 734-734/com.appp.ecovitae D/ViewRootImpl@e9ef8b8[Main2Activity]: dispatchDetachedFromWindow 2020-02-09 15:40:42.107 734-734/com.appp.ecovitae D/InputTransport: Input channel destroyed: fd=68 2020-02-09 15:40:42.115 734-734/com.appp.ecovitae I/CenterCropStrategy: Preview: 1920x1080; Scaled: 2110x1186; Want: 2110x1080 2020-02-09 15:40:42.117 734-734/com.appp.ecovitae D/SurfaceView: show() Surface(name=SurfaceView - com.appp.ecovitae/com.journeyapps.barcodescanner.CaptureActivity@f21a197@0[734])/@0x3314ba2 android.view.SurfaceView{f21a197 V.E...... ......ID 0,-53-2110,1133} 2020-02-09 15:40:42.132 734-734/com.appp.ecovitae D/SurfaceView: surfaceChanged (2110,1186) 1 #5 android.view.SurfaceView{f21a197 V.E...... ......ID 0,-53-2110,1133} 2020-02-09 15:40:42.132 734-734/com.appp.ecovitae I/CameraPreview: Starting preview 2020-02-09 15:40:42.133 734-1074/com.appp.ecovitae D/CameraInstance: Starting preview 2020-02-09 15:40:42.231 734-1074/com.appp.ecovitae I/AutoFocusManager: Current focus mode 'auto'; use auto focus? true 2020-02-09 15:40:44.215 734-1109/com.appp.ecovitae D/DecoderThread: Found barcode in 43 ms 2020-02-09 15:40:44.218 734-734/com.appp.ecovitae D/CameraPreview: pause() 2020-02-09 15:40:44.219 734-1074/com.appp.ecovitae D/CameraInstance: Closing camera 2020-02-09 15:40:44.224 734-734/com.appp.ecovitae D/SensorManager: unregisterListener ::
2020-02-09 15:40:44.225 734-734/com.appp.ecovitae D/CameraInstance: Camera is closed, not requesting preview 2020-02-09 15:40:44.282 734-734/com.appp.ecovitae D/CameraPreview: pause() 2020-02-09 15:40:44.288 734-734/com.appp.ecovitae D/CameraPreview: pause() 2020-02-09 15:40:44.293 734-844/com.appp.ecovitae V/FA: Recording user engagement, ms: 2710 2020-02-09 15:40:44.301 734-844/com.appp.ecovitae V/FA: Activity paused, time: 3029481 2020-02-09 15:40:44.814 734-734/com.appp.ecovitae D/ViewRootImpl@a66ddd8[CaptureActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1 2020-02-09 15:40:44.814 734-734/com.appp.ecovitae D/InputMethodManager: prepareNavigationBarInfo() DecorView@8e10fd[CaptureActivity] 2020-02-09 15:40:44.814 734-734/com.appp.ecovitae D/InputMethodManager: getNavigationBarColor() -855310 2020-02-09 15:40:44.969 734-734/com.appp.ecovitae D/InputTransport: Input channel destroyed: fd=95 2020-02-09 15:40:44.970 734-734/com.appp.ecovitae D/ViewRootImpl@a66ddd8[CaptureActivity]: stopped(true) old=false 2020-02-09 15:40:44.974 734-734/com.appp.ecovitae D/SurfaceView: windowStopped(true) false android.view.SurfaceView{f21a197 V.E...... ........ 0,-53-2110,1133} of ViewRootImpl@a66ddd8[CaptureActivity] 2020-02-09 15:40:44.975 734-734/com.appp.ecovitae D/SurfaceView: show() Surface(name=SurfaceView - com.appp.ecovitae/com.journeyapps.barcodescanner.CaptureActivity@f21a197@0[734])/@0x3314ba2 android.view.SurfaceView{f21a197 V.E...... ........ 0,-53-2110,1133} 2020-02-09 15:40:44.977 734-734/com.appp.ecovitae D/SurfaceView: surfaceDestroyed callback.size 1 #1 android.view.SurfaceView{f21a197 V.E...... ........ 0,-53-2110,1133} 2020-02-09 15:40:44.978 734-734/com.appp.ecovitae D/SurfaceView: destroy() Surface(name=SurfaceView - com.appp.ecovitae/com.journeyapps.barcodescanner.CaptureActivity@f21a197@0[734])/@0x3314ba2 android.view.SurfaceView{f21a197 V.E...... ........ 0,-53-2110,1133} 2020-02-09 15:40:44.988 734-734/com.appp.ecovitae D/SurfaceView: onWindowVisibilityChanged(8) false android.view.SurfaceView{f21a197 V.E...... ........ 0,-53-2110,1133} of ViewRootImpl@a66ddd8[CaptureActivity] 2020-02-09 15:40:44.993 734-916/com.appp.ecovitae W/libEGL: EGLNativeWindowType 0x794a1ab010 disconnect failed 2020-02-09 15:40:44.995 734-916/com.appp.ecovitae D/OpenGLRenderer: eglDestroySurface = 0x7949321880, 0x794a1ab000 2020-02-09 15:40:44.998 734-734/com.appp.ecovitae D/ViewRootImpl@a66ddd8[CaptureActivity]: dispatchDetachedFromWindow 2020-02-09 15:40:45.006 734-734/com.appp.ecovitae D/InputTransport: Input channel destroyed: fd=92 2020-02-09 15:40:46.312 734-844/com.appp.ecovitae D/FA: Application going to the background

kore01 avatar Feb 09 '20 13:02 kore01

Version 3.2.0 is four years old by now - try upgrading to the latest version, and see if you still have the same issue.

rkistner avatar Feb 10 '20 12:02 rkistner

I did, but I changed the version multiple time s trying to resolve the issue.

On Mon, 10 Feb 2020, 14:36 Ralf Kistner, [email protected] wrote:

Version 3.2.0 is four years old by now - try upgrading to the latest version, and see if you still have the same issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/journeyapps/zxing-android-embedded/issues/533?email_source=notifications&email_token=AN3RN4HYDU3RBDSWXRROWGDRCFC5TA5CNFSM4KSBXNEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELILB6Y#issuecomment-584102139, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN3RN4H34GXBARCV4GY3HFLRCFC5TANCNFSM4KSBXNEA .

kore01 avatar Feb 10 '20 12:02 kore01

Unfortunately your logs don't contain enough info to debug this.

If you have a small piece of code directly demonstrating an issue in the library, we can help to debug. Otherwise it's outside the scope of what we can assist with.

rkistner avatar Feb 12 '20 11:02 rkistner

I was having the same problem, in my case the solution was use IntentInegrator with forSupportFragment mode just like this:

val scan: IntentIntegrator = IntentIntegrator.forSupportFragment(yourFragmentHere)

The only change I had to do was capture the scanner result from the onActivityResult who is inside the fragment I passed to the IntentIntegrator. I hope this can be helpfull to someone helse

MaCls98 avatar Jan 27 '21 12:01 MaCls98

I was having the same problem, in my case the solution was use IntentInegrator with forSupportFragment mode just like this:

val scan: IntentIntegrator = IntentIntegrator.forSupportFragment(yourFragmentHere)

The only change I had to do was capture the scanner result from the onActivityResult who is inside the fragment I passed to the IntentIntegrator. I hope this can be helpfull to someone helse

Where do we have to add this?

raininfotech-prapti153 avatar Oct 12 '23 07:10 raininfotech-prapti153