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

There should be a friendly error when calling createCapture with no webcam #6402

Closed
1 of 17 tasks
lindapaiste opened this issue Sep 9, 2023 · 12 comments · Fixed by #6961
Closed
1 of 17 tasks

There should be a friendly error when calling createCapture with no webcam #6402

lindapaiste opened this issue Sep 9, 2023 · 12 comments · Fixed by #6961

Comments

@lindapaiste
Copy link
Contributor

Increasing Access

It can be confusing if a user is looking at an example code which doesn't do anything.

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build Process
  • Unit Testing
  • Internalization
  • Friendly Errors
  • Other (specify if possible)

Feature enhancement details

When I call createCapture(VIDEO) on a device which does not have a webcam, I see a message in the console which is not particularly friendly.

DOMException: Requested device not found

This is actually not an error. createCapture still returns a p5.Element.

This example code will run with no webcam, it just won't do anything -- it creates a transparent image.

let capture;

function setup() {
  createCanvas(100, 100);
  capture = createCapture(VIDEO);
  capture.hide();
}

function draw() {
  image(capture, 0, 0, width, width * capture.height / capture.width);
  filter(INVERT);
}

Other examples on the reference page do have errors.
image

@ayushanand308
Copy link

ayushanand308 commented Sep 10, 2023

We can have something like "No webcam found on this device" instead of the current error message to let the users know that the code is working fine but there is simply no webcam to capture video from.

@Qianqianye
Copy link
Contributor

Thanks @lindapaiste and @ayushanand308. I'm inviting the FES GSoC contributor @Ayush23Dash and mentors @almchung @nbriz to this discussion.

@Ayush23Dash
Copy link
Contributor

Yup, I agree with @ayushanand308 and believe so that we can add an error for the same, also it would be great if we add one more error for Camera Permission denied.
Currently it shows :
DOMException: Permission denied
error, which is somehow descriptive but adding a Friendly Message to it would also be great.

@Qianqianye
Copy link
Contributor

Qianqianye commented Sep 14, 2023

Thanks @Ayush23Dash! What do you think, @almchung and @nbriz?
We can add these error messages if they are approved by two FES stewards and GSoC mentors/contributor.

@ayushanand308
Copy link

@Ayush23Dash Should I begin working on this and submit a pull request?

@Qianqianye
Copy link
Contributor

Thanks @ayushanand308 for the follow up. Please go ahead and submit a PR.
Meanwhile, I'm inviting the new FES stewards to this discussion @richardegil, @itsjoopark, @hannahvy, @bisabi-01, @singshris. Please feel free to leave comments or questions. Thank you.

@richardegil
Copy link

I agree with this. For the permission denied error may I suggest the following: "Camera detected but permission to it has been denied."

@Garima3110
Copy link
Contributor

Hii everyone, I am just a beginner to open source. I know a bit of javascript but still learning. I would like to address this issue , could you please help me through the process?!

@Qianqianye
Copy link
Contributor

Hi @Garima3110. Below are three contributor documentation that you might find helpful:

I will suggest going through the three docs and leave comments here if you have any questions. We are in the process of updating our contributor documentation, so please feel free to let us know how we can improve the docs to make it easier for contributors to get started. Thank you!

@Garima3110
Copy link
Contributor

I think in this case we just need to check for the condition :
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { throw new Error("Your browser does not support webcam access."); }

@Ayush23Dash It would be great if you could tell me whether I am going in the right direction or not?!

@ayushanand308
Copy link

ayushanand308 commented Nov 16, 2023

@Garima3110 The line of code you provided is a standard JS error throw statement, and it will result in a regular error being thrown, not a friendly error. I also think that you would have to make changes in translation.json files.

@Ayush23Dash Also in which existing category of friendly error should this fall, or we should add a new category like "_nodeviceFoundError()"?

@mdb0
Copy link
Contributor

mdb0 commented Apr 10, 2024

Since there isn't much update i would like to work on this issue

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

Successfully merging a pull request may close this issue.

7 participants