Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

录像报错:java.lang.NullPointerException Null surface #2607

Closed
po1xiao opened this issue Mar 6, 2023 · 1 comment
Closed

录像报错:java.lang.NullPointerException Null surface #2607

po1xiao opened this issue Mar 6, 2023 · 1 comment

Comments

@po1xiao
Copy link
Contributor

po1xiao commented Mar 6, 2023

Current use version?

当前使用的版本是多少?

v3.10.7

Will this problem occur in demo?

Demo能否复现这问题?

否,线上小概率问题

Describe the problem or provide an error log?

描述问题或提供错误log?

java.lang.NullPointerException
Null surface
 
androidx.camera.core.impl.AutoValue_SessionConfig_OutputConfig$Builder.setSurface(AutoValue_SessionConfig_OutputConfig.java:103)
androidx.camera.core.impl.SessionConfig$OutputConfig.builder(SessionConfig.java:116)
androidx.camera.core.impl.SessionConfig$Builder.addNonRepeatingSurface(SessionConfig.java:559)
androidx.camera.core.VideoCapture.stopRecording(VideoCapture.java:535)
com.luck.lib.camerax.CustomCameraView$3.recordShort(CustomCameraView.java:372)
com.luck.lib.camerax.widget.CaptureLayout$2.recordShort(CaptureLayout.java:157)
com.luck.lib.camerax.widget.CaptureButton.recordEnd(CaptureButton.java:267)
com.luck.lib.camerax.widget.CaptureButton.handlerPressByState(CaptureButton.java:257)
com.luck.lib.camerax.widget.CaptureButton.onTouchEvent(CaptureButton.java:227)
po1xiao added a commit to po1xiao/PictureSelector that referenced this issue Mar 22, 2023
@po1xiao
Copy link
Contributor Author

po1xiao commented Mar 22, 2023

还有一种情况,是生命周期中报错,可能是因为代码中给VideoCapture绑定了生命周期操作:

 Camera camera = mCameraProvider.bindToLifecycle((LifecycleOwner) getContext(), cameraSelector, preview, mVideoCapture);

这样生命周期中也会调用VideoCapture.stopRecording,代码中也会主动调用VideoCapture.stopRecording,这两种情况就会有竞争,如果代码中先调用,生命周期中的调用就会抛异常,反之亦然。因为recordShort中没有加try-catch,所有有这两处报错。

堆栈如下:
java.lang.RuntimeException:Unable to stop activity {xx/com.luck.lib.camerax.PictureCameraActivity}: java.lang.RuntimeException: Failed to call observer method
android.app.ActivityThread.callActivityOnStop(ActivityThread.java:6347)
......
Caused by:
java.lang.NullPointerException:Null surface
androidx.camera.core.impl.AutoValue_SessionConfig_OutputConfig$Builder.setSurface(AutoValue_SessionConfig_OutputConfig.java:103)
androidx.camera.core.impl.SessionConfig$OutputConfig.builder(SessionConfig.java:116)
androidx.camera.core.impl.SessionConfig$Builder.addNonRepeatingSurface(SessionConfig.java:559)
androidx.camera.core.VideoCapture.stopRecording(VideoCapture.java:535)
androidx.camera.core.VideoCapture.onStateDetached(VideoCapture.java:613)
androidx.camera.camera2.internal.Camera2CameraImpl.notifyStateDetachedToUseCases(Camera2CameraImpl.java:813)
androidx.camera.camera2.internal.Camera2CameraImpl.detachUseCases(Camera2CameraImpl.java:832)
androidx.camera.core.internal.CameraUseCaseAdapter.detachUseCases(CameraUseCaseAdapter.java:347)
androidx.camera.lifecycle.LifecycleCamera.onStop(LifecycleCamera.java:97)
androidx.camera.lifecycle.LifecycleCamera.suspend(LifecycleCamera.java:140)
androidx.camera.lifecycle.LifecycleCameraRepository.suspendUseCases(LifecycleCameraRepository.java:444)
androidx.camera.lifecycle.LifecycleCameraRepository.setInactive(LifecycleCameraRepository.java:389)
androidx.camera.lifecycle.LifecycleCameraRepository$LifecycleCameraRepositoryObserver.onStop(LifecycleCameraRepository.java:515)
java.lang.reflect.Method.invoke(Native Method)
androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:225)
androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:199)
androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:190)
androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:40)
androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:360)
androidx.lifecycle.LifecycleRegistry.backwardPass(LifecycleRegistry.java:290)
androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:308)
androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:151)
androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:134)
androidx.lifecycle.ReportFragment.dispatch(ReportFragment.java:68)
androidx.lifecycle.ReportFragment$LifecycleCallbacks.onActivityPreStopped(ReportFragment.java:210)
android.app.Activity.dispatchActivityPreStopped(Activity.java:1514)
android.app.Activity.performStop(Activity.java:8720)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants