{"record":{"id":"168e673b857ff0b3","repo":"SubtitleEdit/subtitleedit","slug":"unsupported-platform-for-libmpv-download-runtime","errorCode":null,"errorMessage":"Unsupported platform for libmpv download.\n{RuntimeInformation.OSDescription}","messagePattern":"Unsupported platform for libmpv download\\.\n(.+?)","errorType":"exception","errorClass":"PlatformNotSupportedException","httpStatus":null,"severity":"critical","filePath":"src/ui/Logic/Download/LibMpvDownloadService .cs","lineNumber":41,"sourceCode":"    private const string MacUrlArm = \"\";\n\n    public LibMpvDownloadService(HttpClient httpClient)\n    {\n        _httpClient = httpClient;\n    }\n\n    private static string GetUrl()\n    {\n        if (OperatingSystem.IsWindows())\n        {\n            // A native ARM64 process cannot load an x64 DLL, so the download\n            // must match the process architecture (issue #12087).\n            return RuntimeInformation.ProcessArchitecture == Architecture.Arm64\n                ? WindowsUrlArm\n                : WindowsUrl;\n        }\n\n        throw new PlatformNotSupportedException(\"Unsupported platform for libmpv download.\" + Environment.NewLine +\n            RuntimeInformation.OSDescription);\n\n        //if (OperatingSystem.IsMacOS())\n        //{\n        //    switch (RuntimeInformation.ProcessArchitecture)\n        //    {\n        //        case Architecture.Arm64:\n        //            return MacUrlArm; // e.g., for M1, M2, M3, M4 chips\n        //        case Architecture.X64:\n        //            return MacUrl;\n        //        default:\n        //            throw new PlatformNotSupportedException(\"Unsupported macOS architecture.\");\n        //    }\n        //}\n\n        //throw new PlatformNotSupportedException();\n    }\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Logic/Download/LibMpvDownloadService .cs#L23-L59","documentation":"Thrown by LibMpvDownloadService.GetUrl() — currently only Windows (with ARM64 vs x64 selection) returns a URL; macOS and Linux branches are commented out, so any non-Windows OS falls straight to 'throw new PlatformNotSupportedException(\"Unsupported platform for libmpv download.\" + Environment.NewLine + RuntimeInformation.OSDescription)'. The OSDescription is appended to aid debugging.","triggerScenarios":"Calling the libmpv download path on macOS or Linux (both branches commented out), or any non-Windows OS. The Windows branch itself selects WindowsUrlArm for Arm64 and WindowsUrl otherwise (issue #12087: native ARM64 process cannot load x64 DLL).","commonSituations":"Cross-platform build run on macOS/Linux where libmpv download was disabled; a refactor that left only Windows enabled; user expecting Linux/macOS libmpv auto-download. The commented code shows the intended future Mac switch.","solutions":["On macOS/Linux, install libmpv via the OS package manager / Homebrew instead of the auto-download path.","If you need cross-platform auto-download, uncomment and populate the macOS/Linux URL constants with valid libmpv builds.","On Windows, ensure the process architecture matches the binary (ARM64 process gets WindowsUrlArm) — do not force x64 on an ARM64 process."],"exampleFix":"// before: only Windows supported\nif (OperatingSystem.IsWindows()) { /* ... */ return RuntimeInformation.ProcessArchitecture == Architecture.Arm64 ? WindowsUrlArm : WindowsUrl; }\nthrow new PlatformNotSupportedException(\"Unsupported platform for libmpv download.\" + Environment.NewLine + RuntimeInformation.OSDescription);\n\n// after: restore macOS support\nif (OperatingSystem.IsWindows()) { /* ... */ }\nif (OperatingSystem.IsMacOS())\n{\n    return RuntimeInformation.ProcessArchitecture == Architecture.Arm64 ? MacUrlArm : MacUrl;\n}\nthrow new PlatformNotSupportedException(\"Unsupported platform for libmpv download.\" + Environment.NewLine + RuntimeInformation.OSDescription);","handlingStrategy":"validation","validationCode":"static bool IsLibMpvDownloadSupported()\n    => OperatingSystem.IsWindows(); // only Windows is wired up\n\nif (!IsLibMpvDownloadSupported()) { UseSystemLibMpvInstall(); return; }","typeGuard":"static bool LibMpvDownloadSupported() => OperatingSystem.IsWindows();","tryCatchPattern":"try { var url = LibMpvDownloadService.GetUrl(); }\ncatch (PlatformNotSupportedException ex) when (!OperatingSystem.IsWindows())\n{ _logger.Warning(\"libmpv auto-download is Windows-only: {OS}\", RuntimeInformation.OSDescription); UseSystemLibMpvInstall(); }","preventionTips":["On macOS/Linux install libmpv via Homebrew/apt/dnf instead of auto-download.","Keep the commented-out branches visible as a roadmap; uncomment with valid URLs when ready.","On Windows, match process arch to the binary (ARM64 process -> WindowsUrlArm)."],"tags":["platform","libmpv","download","windows-only","commented-out"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}