actions / runner-images

GitHub Actions runner images
MIT License
9.82k stars 3.01k forks source link

macos-14 runner cannot play sound because of microphone permission dialog box #9330

Closed ychin closed 7 months ago

ychin commented 7 months ago

Description

The new macos-14 runner seems to have problems playing audio. When attempting to play a sound, a microphone permission dialog would come up, preventing the task from completing. Interestingly this doesn't happen in macos-12 or macos-13. I also couldn't reproduce this issue locally on a MacBook Pro, so I wonder if it has to do with the way the audio device is set up on the GitHub Actions image. Searching this on Google didn't yield much results.

Platforms affected

Runner images affected

Image version and build link

GitHub Actions:

  Image: macos-14-arm64
  Version: 20240116.1
  Included Software: https://github.com/actions/runner-images/blob/macOS-14/20240116.1/images/macos/macos-14-arm64-Readme.md
  Image Release: https://github.com/actions/runner-images/releases/tag/macOS-14%2F20240116.1

Is it regression?

no

Expected behavior

The task completes after playing a sound.

Actual behavior

The task hangs in macos-14, and then pops up a microphone permission dialog box. Below is dumped from taking a screenshot in the CI environment:

image

Repro steps

Add the following in a GitHub Actions yaml:

jobs:
  macos:
    runs-on: ${{ matrix.runner }}

    strategy:
      fail-fast: false
      matrix:
        runner: [macos-latest, macos-13, macos-14]

    steps:
      - name: Play a sound
        timeout-minutes: 3
        run: |
          (sleep 10; screencapture debugscreen_${{ matrix.runner }}.png) &
          afplay /System/Library/Sounds/Funk.aiff
          sleep 20

      - name: Publish debug screenshot
        if: success() || failure()
        uses: actions/upload-artifact@v4
        with:
          name: debugscreen_${{ matrix.runner }}.png
          path: debugscreen_${{ matrix.runner }}.png

afplay is supposed to play a sound file and complete. The screencapture is there to take a screenshot only to debug the issue.

Alexey-Ayupov commented 7 months ago

Hello @ychin, we will take a look.

sergei-pyshnoi commented 7 months ago

Hello @ychin . As workaround you can add step bellow to your workflow for granting access to microphone .

 - name: Grant microphone access
        run: |
          sqlite3 $HOME/Library/Application\ Support/com.apple.TCC/TCC.db "INSERT OR IGNORE INTO access VALUES ('kTCCServiceMicrophone','/usr/local/opt/runner/provisioner/provisioner',1,2,4,1,NULL,NULL,0,'UNUSED',NULL,0,1687786159,NULL,NULL,'UNUSED',1687786159);"

I used it with provided repro, and looks like everything finishes without errors.

ychin commented 7 months ago

Oh cool. Thanks, I will give that a try.

mikhailkoliada commented 7 months ago

Did workaround help so far? :)

ychin commented 7 months ago

Yes, it did! See https://github.com/vim/vim/pull/14032

mikhailkoliada commented 7 months ago

Good to know! Closing for now as we do not have plans to add this to tccdb by default just yet (might be in the future we will if we see more problems like this), if you have more questions feel free to reach us out again :)

ychin commented 7 months ago

Ok. Thanks. I still find it really curious why macOS requests a microphone permission while we are just playing a sound. It seems like an odd macOS quirk at least because I don't think it happens locally on my MacBook Pro. Either way probably not a big deal as there's a way to just grant the permission.

mikhailkoliada commented 7 months ago

@ychin it happens to macOS quite naturally between releases, check your local tccdb, most likely it has the kTCCServiceMicrophone permissions set accordingly

stephenwade commented 4 months ago

@mikhailkoliada I am also running into this issue. Is there any possibility to reconsider fixing this in the base image?

mxschmitt commented 4 months ago

I think it affects all Playwright (end-to-end testing framework which uses) who are using Chromium or Firefox to play audio or video.

ADKaster commented 4 months ago

This also impacts the Ladybird Browser's Audio tests on macOS 14. We use AudioUnit for setting up Audio output streams. https://github.com/SerenityOS/serenity/commit/a447b9bffd2d0740816c399f3a1f3cc1745c6686

codebytere commented 2 months ago

@mikhailkoliada this also affects Electron's test suites - we're working around the issue for now but i'd be happy to open a PR if it'd be considered at this point.

t3chguy commented 2 months ago

Element is having to employ similar workarounds for Playwright testing of Electron, worked around in https://github.com/element-hq/element-desktop/blob/aa5d8e9e06fcd4e93b6ec736eefcf8027194003b/.github/workflows/build_and_test.yaml#L131-L135