Skip to content

Camera permissions aren't working on packaged app #23

@davepagurek

Description

@davepagurek

Most appropriate sub-area of Processing 4?

IO

Processing version

p5.js mode 0.6

Operating system

MacOS 15.2

Bug description

In my p5 script, I use createCapture(VIDEO). This works in the Processing app, but after exporting a packaged application, when I run the app, it doesn't ask me for camera permissions, and the video feed never loads. (It seems like on a slightly older MacOS 14 machine, it DOES still ask permissions, and everything works.)

Steps to reproduce this

Create a new p5.js project and copy and paste a sketch from the createCapture reference: https://beta.p5js.org/reference/p5/createcapture/

snippet

No response

Additional context

I did a little digging around and found that this blog post works for me: https://www.bigbinary.com/blog/request-camera-micophone-permission-electron

I had to:

  • Create an entitlements.plist file in the sketch folder with camera and mic permissions
  • Optionally write a message in the package.json build settings for Mac that will be shown when requesting permissions
  • Update the build settings in package.json to link to the entitlements.plist file
  • In main.js, run the following:
    const { systemPreferences } = require('electron');
    systemPreferences.askForMediaAccess('camera');
    systemPreferences.askForMediaAccess('microphone');

I'm not 100% sure if that last step is necessary -- the previous steps definitely are, but once I got it asking for permissions for me, it seems to just remember that I've given permissions, and then it just works from then on. Not sure if there's an easy way to get my mac to forget so that I can test again.

All of this is unnecessary if your app doesn't use these permissions. Maybe these could be added based on checkboxes shown in a settings window before exporting your application?

Would you like to work on the issue?

No, I’m just reporting the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions