sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
804 stars 39 forks source link

[Mac] Sublime does not ask for permission to use Webcamera or Microphone. #5606

Open lazer-dinosaur opened 1 year ago

lazer-dinosaur commented 1 year ago

Description of the bug

I'm writing some software in python that requires access to both the webcam and the microphone. When running very simple test scripts that use the camera and/or microphone in VSC or from iterm2 it works fine - on the first occasion a prompt appears asking for permission, and then the code runs successfully. However Sublime Text does not trigger asking for permission, and it seems impossible to grant ST permission.

Steps to reproduce

install opencv and pyaudio

execute this code, normally a window should appear and show the webcam output (works fine in VSC or from terminal):

import cv2

vid = cv2.VideoCapture(0)
while 1:
    ret, frame = vid.read()
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

vid.release()
cv2.destroyAllWindows()

Try this code for the microphone, (the code runs but the saved .wav is empty, ie. microphone is not used):

import pyaudio
import wave

CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "output.wav"

p = pyaudio.PyAudio()

stream = p.open(format=FORMAT,
                channels=CHANNELS,
                rate=RATE,
                input=True,
                frames_per_buffer=CHUNK)

print("* recording")

frames = []

for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
    data = stream.read(CHUNK)
    frames.append(data)

print("* done recording")

stream.stop_stream()
stream.close()
p.terminate()

wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b''.join(frames))
wf.close()

Expected behavior

A window should pop up asking for permission for Sublime to use the Camera and/or microphone. After granting permission the code should then run, and a window showing the camera image should appear (or audio is recorded).

Actual behavior

Nothing happens, the video code exits silently with no error. The audio-code runs, but as it cannot access the microphone, nothing is recorded.

Sublime Text build number

4129

Operating system & version

MacOS 12.4

(Linux) Desktop environment and/or window manager

No response

Additional information

No response

OpenGL context information

No response

BenjaminSchaaf commented 1 year ago

VSCode and others have had similar problems due to Apple's permission changes: https://github.com/microsoft/vscode/issues/95062

BenjaminSchaaf commented 1 year ago

Should be fixed in build 4144.

moooooo16 commented 8 months ago

Has this been solved? I found it was solved in previous versions, but when It desert seems like to work.

ST version: 4169 MacOS: 14.2.1

Use opencv-python: ` import cv2 as cv cap = cv.VideoCapture(0)

while True:

ret, frame = cap.read()
cv.imshow(window_name, frame)

`

and that gives: OpenCV: not authorized to capture video (status 0), requesting... OpenCV: camera failed to properly initialize!

With no window pops up ask for permissions.

I have tried re-install and tccutil reset Camera

Thanks

BenjaminSchaaf commented 8 months ago

Does it work outside of Sublime Text @moooooo16 ?

moooooo16 commented 8 months ago

Does it work outside of Sublime Text @moooooo16 ?

Yes. It worked on cml and vscode.

BenjaminSchaaf commented 7 months ago

Can confirm this doesn't seem fixed.

BenjaminSchaaf commented 7 months ago

This should be fixed in build 4170.

lazer-dinosaur commented 6 months ago

Unfortunately, this still does not work for me. Im on build 4173.