Skip to content

VIVO手机反复进入拍照界面黑屏 #213

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

Closed
zhangshuqi opened this issue Oct 19, 2023 · 10 comments · Fixed by #280
Closed

VIVO手机反复进入拍照界面黑屏 #213

zhangshuqi opened this issue Oct 19, 2023 · 10 comments · Fixed by #280
Labels
b: flutter This is a flutter issue. b: third party This is a third party package issue. i: out of support The issue is out of basic support and not a feature request. r: camera Related to the camera package.

Comments

@zhangshuqi
Copy link

zhangshuqi commented Oct 19, 2023

Describe the bug
VIVO手机反复进入拍照界面黑屏的问题

How to reproduce
DEMO可以复现改问题

Steps to reproduce the behavior:
反复进入拍照界面.

Version information

  • Device: VIVO X23
  • OS: ANDROID 9
  • Package Version: 4.0.2
  • Flutter Version: 3.15.5

Additional context

关键日志:不知是否有帮助?
CameraService: onTorchStatusChangedLocked: cannot get torch status of camera 1: No such file or directory (-2)

log.txt

@zhangshuqi zhangshuqi added the await investigate The issue is waiting for further investigation. label Oct 19, 2023
@AlexV525
Copy link
Member

请前往 camera 提交 issue。

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2023
@zhangshuqi zhangshuqi changed the title [BUG] Error with something VIVO手机反复进入拍照界面黑屏 Oct 19, 2023
@AlexV525 AlexV525 added b: flutter This is a flutter issue. b: third party This is a third party package issue. r: camera Related to the camera package. i: out of support The issue is out of basic support and not a feature request. and removed await investigate The issue is waiting for further investigation. labels Oct 19, 2023
@Tindtily
Copy link

Tindtily commented Oct 25, 2024

我跟踪了一下这个项目以及camera的代码。出现问题的是这里:

出错以后,这一行代码都不会被执行到:realDebugPrint("${stopwatch.elapsed} for config's update.");

如果删除setFlashMode相关代码,就不会黑屏了。

当然你可以说是camera的问题。但是调用方式是直接原因。

复现手机:HUAWEI Mate 30E Pro 5G
操作系统: HarmonyOS 2.0.0

@AlexV525
Copy link
Member

出错后会重新再尝试一次,再次尝试的时候不会再调用 setFlashMode。

@Tindtily
Copy link

出错后会重新再尝试一次,再次尝试的时候不会再调用 setFlashMode。

实际测试,并没有再次尝试,必须关闭页面重新进入才有可能恢复

@AlexV525
Copy link
Member

请尝试把该调用改为:

// Do not set flash modes for the front camera.
Future(() async {
  final flashMode = pickerConfig.preferredFlashMode;
  if (validFlashModes[description]?.contains(flashMode) != false &&
      description.lensDirection != CameraLensDirection.front &&
      flashMode != FlashMode.auto) {
    return wrapControllerMethod<void>(
      'setFlashMode',
      () => newController.setFlashMode(
        flashMode,
      ),
      description: description,
      onError: () {
        validFlashModes[description]?.remove(flashMode);
      },
    );
  }
})

@Tindtily
Copy link

请尝试把该调用改为:

// Do not set flash modes for the front camera.
Future(() async {
  final flashMode = pickerConfig.preferredFlashMode;
  if (validFlashModes[description]?.contains(flashMode) != false &&
      description.lensDirection != CameraLensDirection.front &&
      flashMode != FlashMode.auto) {
    return wrapControllerMethod<void>(
      'setFlashMode',
      () => newController.setFlashMode(
        flashMode,
      ),
      description: description,
      onError: () {
        validFlashModes[description]?.remove(flashMode);
      },
    );
  }
})

问题依旧,方法一直都会调用,但是java那边抛出一个提醒: [ ] I/Camera (25092): refreshPreviewCaptureSession: captureSession not yet initialized, skipping preview capture session refresh.

java抛出的位置:

https://github.com/flutter/packages/blob/ca8cb667042bdf485601be2a51eccde4692d54b3/packages/camera/camera_android/android/src/main/java/io/flutter/plugins/camera/Camera.java#L558

然后后面的代码就不执行了,好奇怪,不太懂flutter。

@Tindtily
Copy link

真正的错误应该是这样的,但是不知道是哪里跑出来的,而且这个错误不是实时抛出来的,会延迟一段时间:

[  +52 ms] W/System  (25092): A resource failed to call release. 
[        ] E/System  (25092): Uncaught exception thrown by finalizer
[        ] E/System  (25092): java.util.concurrent.RejectedExecutionException: Task android.hardware.camera2.impl.-$$Lambda$CallbackProxies$SessionStateCallbackProxy$9H0ZdANdMrdpoq2bfIL2l3DVsKk@92e05ac rejected from java.util.concurrent.ThreadPoolExecutor@d5b0275[Shutting down, pool size = 1, active threads = 0, queued tasks = 0, completed tasks = 3]
[        ] E/System  (25092): 	at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2086)
[        ] E/System  (25092): 	at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:848)
[        ] E/System  (25092): 	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1394)
[        ] E/System  (25092): 	at java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:630)
[        ] E/System  (25092): 	at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.onClosed(CallbackProxies.java:104)
[        ] E/System  (25092): 	at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:535)
[        ] E/System  (25092): 	at android.hardware.camera2.impl.CameraCaptureSessionImpl.finalize(CameraCaptureSessionImpl.java:826)
[        ] E/System  (25092): 	at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:289)

@AlexV525
Copy link
Member

已测试不会再调用,其他问题请给出详细信息后开新 issue。

@Tindtily
Copy link

已测试不会再调用,其他问题请给出详细信息后开新 issue。

并不是调用失败的问题吧。
看上去好像是被阻塞了,整个Future[]都阻塞了,导致后面的代码,比如 503行: realDebugPrint("${stopwatch.elapsed} for config's update."); 都不会执行到。哪怕是setFlashMode出错了,但是可以继续执行的话,也不会黑屏了。

这就是黑屏的issue,我说的也是黑屏的问题,还需要再重新开一个?

@AlexV525
Copy link
Member

出错以后,这一行代码都不会被执行到:realDebugPrint("${stopwatch.elapsed} for config's update."); 如果删除setFlashMode相关代码,就不会黑屏了。

当然你可以说是camera的问题。但是调用方式是直接原因。

并不是调用失败的问题吧。

这里你的描述是调用失败导致的黑屏,现在不是了?

这就是黑屏的issue,我说的也是黑屏的问题,还需要再重新开一个?

黑屏的原因不一样的情况下不是同一个问题。

@fluttercandies fluttercandies locked as off-topic and limited conversation to collaborators Oct 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
b: flutter This is a flutter issue. b: third party This is a third party package issue. i: out of support The issue is out of basic support and not a feature request. r: camera Related to the camera package.
Projects
None yet
3 participants