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

【Android】-【7.6.5011】:【拍照按钮快速连续点击会导致RuntimeException】 #1381

Open
tashuodeni opened this issue Dec 28, 2023 · 2 comments

Comments

@tashuodeni
Copy link

tashuodeni commented Dec 28, 2023

issue标题:

【Android】-【7.6.5011】:【拍照按钮快速连续点击会导致RuntimeException】
issue内容:

【当前现象】:聊天界面点击拍照,进入CameraActivity,快速连续点击拍照按钮会导致 java.lang.RuntimeException: takePicture failed
【集成包】:TUIKIT
【机型】:魅族18Pro
【之前版本有无此问题】:应该一直存在
【有无日志或者描述、截图】:
java.lang.RuntimeException: takePicture failed
at android.hardware.Camera.native_takePicture(Native Method)
at android.hardware.Camera.takePicture(Camera.java:1630)
at android.hardware.Camera.takePicture(Camera.java:1571)
at com.tencent.qcloud.tuikit.tuichat.component.camera.view.CameraInterface.takePicture(CameraInterface.java:327)
at com.tencent.qcloud.tuikit.tuichat.component.camera.state.PreviewState.capture(PreviewState.java:49)
at com.tencent.qcloud.tuikit.tuichat.component.camera.state.CameraMachine.capture(CameraMachine.java:75)
at com.tencent.qcloud.tuikit.tuichat.component.camera.view.CameraView$2.takePictures(CameraView.java:155)
at com.tencent.qcloud.tuikit.tuichat.component.camera.view.CaptureLayout$2.takePictures(CaptureLayout.java:134)
at com.tencent.qcloud.tuikit.tuichat.component.camera.view.CaptureButton$2.onAnimationEnd(CaptureButton.java:220)
at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:600)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1333)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1575)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:326)
at android.animation.AnimationHandler.-$$Nest$mdoAnimationFrame(Unknown Source:0)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:86)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1439)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1449)
at android.view.Choreographer.doCallbacks(Choreographer.java:1097)
at android.view.Choreographer.doFrame(Choreographer.java:1023)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1414)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:8045)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)

------------------------- 修复方案 -------------------------
可在PreviewState类中添加标志位

class PreviewState implements State {
    private boolean capturing = false;

    @Override
    public void capture() {
        TUIChatLog.i(TAG, "capture");

        if (capturing) {
            return;
        }

        capturing = true;
        CameraInterface.getInstance().takePicture(new CameraInterface.TakePictureCallback() {
            @Override
            public void captureResult(Bitmap bitmap, boolean isVertical) {
                capturing = false;
                String path = FileUtil.generateImageFilePath();
                boolean result = FileUtil.saveBitmap(path, bitmap);
                if (!result) {
                    TUIChatLog.e(TAG, "take picture save bitmap failed");
                }
                machine.getCameraView().showPicture(bitmap, isVertical);
                machine.getBrowserPictureState().setDataPath(path);
                machine.setState(machine.getBrowserPictureState());
            }
        });
    }
}
@tashuodeni
Copy link
Author

92_1703764862.mp4

复现视频

@tashuodeni
Copy link
Author

WX20231228-200311@2x
错误堆栈

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

1 participant