Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Unity Android deadlocks when trying to use WebcamSource #335

Closed
djee-ms opened this issue May 11, 2020 · 1 comment
Closed

Unity Android deadlocks when trying to use WebcamSource #335

djee-ms opened this issue May 11, 2020 · 1 comment
Assignees
Labels
bug Something isn't working platform:android Android specific issues

Comments

@djee-ms
Copy link
Member

djee-ms commented May 11, 2020

Describe the bug
When deploying on Android some Unity project trying to use WebcamSource, some exception is thrown since the local video capture is not implemented. This exception is not caught, and results in a deadlock, blocking the main Unity app thread forever.

To Reproduce
Steps to reproduce the behavior:

  1. Deploy the VideoChatDemo sample scene to Android
  2. Run it from Android Studio

Expected behavior
WebcamSource fails to start, logs an error because local video capture is not yet implemented, and application execution continues.

Environment

  • Platform: Unity Android Player
  • Architecture: arm64-v8a
  • Unity version: 2019.3.13f1
  • Target device: Google Pixel 3A

Additional context
The exception likely needs to be caught before control returns to Unity after executing one of the handlers. Currently StartCaptureAsync() is called from OnEnabled() first, and also from StartConnection() if clicking the Connect button in the UI.

@djee-ms djee-ms added bug Something isn't working platform:android Android specific issues labels May 11, 2020
@djee-ms djee-ms self-assigned this May 11, 2020
djee-ms added a commit to djee-ms/MixedReality-WebRTC that referenced this issue Jul 1, 2020
Catch exceptions when failing to create a device track source in
WebcamSource and MicrophoneSource components, and disable the component
before re-throwing the exception to get Unity to log it. This ensures
that the components are disabled for consistency.

This is a clean-up loosely related to microsoft#335, though the code triggering
that issue has been changed so the issue does not occur anymore.
@djee-ms
Copy link
Member Author

djee-ms commented Jul 1, 2020

Confirmed this doesn't occur anymore on master with the most recent changes, as the code in WebcamSource was refactored to do its work inside OnEnable() so cannot deadlock anymore.

@djee-ms djee-ms closed this as completed Jul 1, 2020
djee-ms added a commit to djee-ms/MixedReality-WebRTC that referenced this issue Jul 3, 2020
Catch exceptions when failing to create a device track source in
WebcamSource and MicrophoneSource components, and disable the component
before re-throwing the exception to get Unity to log it. This ensures
that the components are disabled for consistency.

This is a clean-up loosely related to microsoft#335, though the code triggering
that issue has been changed so the issue does not occur anymore.
djee-ms added a commit that referenced this issue Jul 3, 2020
Catch exceptions when failing to create a device track source in WebcamSource
and MicrophoneSource components, and log the exception with its callstack along
with an error message with the component name.

This is a clean-up loosely related to #335, though the code triggering that
issue has been changed so the issue does not occur anymore.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working platform:android Android specific issues
Projects
None yet
Development

No branches or pull requests

1 participant