【问题解决】老Mac使用Opencore Legacy Patcher升级新系统后Chrome等软件卡死

Python3.8

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

这里写自定义目录标题

情况

老Mac使用Opencore Legacy Patcher升级新系统后QQ等使用Electron的软件和Chrome显示错误

条件

  1. 使用Chrome 125+和一些基于Electron的应用程序(如QQ、Visual Studio Code)
  2. 基于AMD GCN 1.0的GPU
  3. 运行Ventura或更新版本

问题表现

出现严重UI问题或者卡死,界面泛红。

影响范围

  • AMD HD 7000 series
  • FirePro D300/D500/D700 (Mac Pro Late 2013 / MacPro6,1)
  • R9 M370X (MacBook Pro 15" 2015 / MacBookPro11,5)

解决办法

方法1:使用下面方式打开软件

open /Applications/Visual\ Studio\ Code.app --args --use-angle=gl
# 这里也可以换成--args --disable-gpu

方法2:使用3.11以上版本的Python运行下面脚本,但是不能保证能覆盖所有app

"""
electron_patcher.py: Enforce 'use-angle@1' in Chrome and Electron applications

Version 1.0.0 (2024-08-11)
"""

import enum
import json

from pathlib import Path


class ChromiumSettingsPatcher:

    class AngleVariant(enum.Enum):
        Default = "0"
        OpenGL = "1"
        Metal = "2"

    def __init__(self, state_file: str) -> None:
        self._local_state_file = Path(state_file).expanduser()


    def patch(self) -> None:
        """
        Ensure 'use-angle@1' is set in Chrome's experimental settings
        """
        _desired_key   = "use-angle"
        _desired_value = self.AngleVariant.OpenGL.value

        if not self._local_state_file.exists():
            print("  Local State missing, creating...")
            self._local_state_file.parent.mkdir(parents=True, exist_ok=True)
            state_data = {}
        else:
            print("  Parsing Local State file")
            state_data = json.loads(self._local_state_file.read_bytes())


        if "browser" not in state_data:
            state_data["browser"] = {}
        if "enabled_labs_experiments" not in state_data["browser"]:
            state_data["browser"]["enabled_labs_experiments"] = []

        for key in state_data["browser"]["enabled_labs_experiments"]:
            if "@" not in key:
                continue

            key_pair = key.split("@")
            if len(key_pair) < 2:
                continue
            if key_pair[0] != _desired_key:
                continue
            if key_pair[1] == _desired_value:
                print(f"  {_desired_key}@{_desired_value} is already set")
                break

            index = state_data["browser"]["enabled_labs_experiments"].index(key)
            state_data["browser"]["enabled_labs_experiments"][index] = f"{_desired_key}@{_desired_value}"
            print(f"  Updated {_desired_key}@{_desired_value}")

        if f"{_desired_key}@{_desired_value}" not in state_data["browser"]["enabled_labs_experiments"]:
            state_data["browser"]["enabled_labs_experiments"].append(f"{_desired_key}@{_desired_value}")
            print(f"  Added {_desired_key}@{_desired_value}")

        print("  Writing to Local State file")
        self._local_state_file.write_text(json.dumps(state_data, indent=4))


def main():
    # Patch all Electron applications
    for directory in Path("~/Library/Application Support").expanduser().iterdir():
        if not directory.is_dir():
            continue

        state_file = directory / "Local State"
        if not state_file.exists():
            continue

        print(f"Patching {directory.name}")
        patcher = ChromiumSettingsPatcher(state_file)
        patcher.patch()

    # Patch all Chrome variants
    if Path("~/Library/Application Support/Google").expanduser().exists():
        for directory in Path("~/Library/Application Support/Google").expanduser().iterdir():
            if not directory.is_dir():
                continue

            state_file = directory / "Local State"
            if not state_file.exists():
                continue

            print(f"Patching {directory.name}")
            patcher = ChromiumSettingsPatcher(state_file)
            patcher.patch()


if __name__ == "__main__":
    main()

您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值