-
Notifications
You must be signed in to change notification settings - Fork 137
fix(macos): fall back to browser capture on Monterey #518
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
Open
arhxam
wants to merge
3
commits into
getopenscreen:main
Choose a base branch
from
arhxam:codex/fix-monterey-recording
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+175
−15
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { describe, expect, it, vi } from "vitest"; | ||
| import { | ||
| isNativeMacCaptureOsSupported, | ||
| resolveNativeMacCaptureHelper, | ||
| } from "./nativeMacCaptureSupport"; | ||
|
|
||
| describe("isNativeMacCaptureOsSupported", () => { | ||
| it("rejects Monterey before probing the macOS 13-only helper", () => { | ||
| expect(isNativeMacCaptureOsSupported("darwin", "12.7.6")).toBe(false); | ||
| }); | ||
|
|
||
| it("accepts Ventura and later macOS releases", () => { | ||
| expect(isNativeMacCaptureOsSupported("darwin", "13.0")).toBe(true); | ||
| expect(isNativeMacCaptureOsSupported("darwin", "26.5.1")).toBe(true); | ||
| }); | ||
|
|
||
| it("rejects other platforms and malformed macOS versions", () => { | ||
| expect(isNativeMacCaptureOsSupported("win32", "13.0")).toBe(false); | ||
| expect(isNativeMacCaptureOsSupported("darwin", "unknown")).toBe(false); | ||
| expect(isNativeMacCaptureOsSupported("darwin", "13.invalid")).toBe(false); | ||
| expect(isNativeMacCaptureOsSupported("darwin", "13beta")).toBe(false); | ||
| expect(isNativeMacCaptureOsSupported("darwin", "")).toBe(false); | ||
| }); | ||
|
|
||
| it("does not look up the helper on Monterey", async () => { | ||
| const findHelper = vi.fn(async () => "/Applications/OpenScreen/helper"); | ||
|
|
||
| await expect(resolveNativeMacCaptureHelper("darwin", "12.7.6", findHelper)).resolves.toEqual({ | ||
| available: false, | ||
| reason: "unsupported-os", | ||
| }); | ||
| expect(findHelper).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("does not look up the helper on unsupported platforms", async () => { | ||
| const findHelper = vi.fn(async () => "/Applications/OpenScreen/helper"); | ||
|
|
||
| await expect(resolveNativeMacCaptureHelper("win32", "13.0", findHelper)).resolves.toEqual({ | ||
| available: false, | ||
| reason: "unsupported-platform", | ||
| }); | ||
| expect(findHelper).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it("reports missing and available helpers on supported macOS versions", async () => { | ||
| const findMissingHelper = vi.fn(async () => null); | ||
| await expect( | ||
| resolveNativeMacCaptureHelper("darwin", "13.0", findMissingHelper), | ||
| ).resolves.toEqual({ available: false, reason: "missing-helper" }); | ||
| expect(findMissingHelper).toHaveBeenCalledOnce(); | ||
|
|
||
| const findAvailableHelper = vi.fn(async () => "/Applications/OpenScreen/helper"); | ||
| await expect( | ||
| resolveNativeMacCaptureHelper("darwin", "13.0", findAvailableHelper), | ||
| ).resolves.toEqual({ | ||
| available: true, | ||
| helperPath: "/Applications/OpenScreen/helper", | ||
| }); | ||
| expect(findAvailableHelper).toHaveBeenCalledOnce(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /** ScreenCaptureKit recording in OpenScreen is built with a macOS 13 deployment target. */ | ||
| export function isNativeMacCaptureOsSupported(platform: NodeJS.Platform, version: string) { | ||
| if (platform !== "darwin" || !/^\d+(?:\.\d+)*$/.test(version)) { | ||
| return false; | ||
| } | ||
|
|
||
| return Number(version.split(".")[0]) >= 13; | ||
| } | ||
|
|
||
| /** Resolve the native helper only on macOS versions that can execute it. */ | ||
| export async function resolveNativeMacCaptureHelper( | ||
| platform: NodeJS.Platform, | ||
| version: string, | ||
| findHelper: () => Promise<string | null>, | ||
| ) { | ||
| if (platform !== "darwin") { | ||
| return { available: false as const, reason: "unsupported-platform" as const }; | ||
| } | ||
| if (!isNativeMacCaptureOsSupported(platform, version)) { | ||
| return { available: false as const, reason: "unsupported-os" as const }; | ||
| } | ||
|
|
||
| const helperPath = await findHelper(); | ||
| return helperPath | ||
| ? { available: true as const, helperPath } | ||
| : { available: false as const, reason: "missing-helper" as const }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.