High CPU usage on macos codex extension

Resolved 💬 1 comment Opened Apr 6, 2026 by Smexey Closed Apr 8, 2026

What version of the IDE extension are you using?

26.5401.11717

What subscription do you have?

Pro

Which IDE are you using?

VS Code

What platform is your computer?

Darwin 25.4.0 arm64 arm

What issue are you seeing?

I have a script to fix this locally, for the version im reporting the bug for (pre release at this time). Please use these as inspiration for a fix.

#!/usr/bin/env bash
#
# Source-aware local workaround for Codex VS Code CPU hotspots.
# This patches the installed extension bundle in-place and keeps a .bak copy.

set -euo pipefail

EXT_DIR=$(ls -d ~/.vscode/extensions/openai.chatgpt-*-darwin-arm64 2>/dev/null | sort -V | tail -1)

if [[ -z "${EXT_DIR:-}" ]]; then
    echo "ERROR: Could not find Codex extension directory."
    exit 1
fi

BUNDLE=$(ls "$EXT_DIR"/webview/assets/index-*.js 2>/dev/null | head -1)
EXT_HOST="$EXT_DIR/out/extension.js"

if [[ -z "${BUNDLE:-}" ]]; then
    echo "ERROR: Could not find Codex webview bundle."
    exit 1
fi

if [[ ! -f "$EXT_HOST" ]]; then
    echo "ERROR: Could not find Codex extension host bundle."
    exit 1
fi

echo "Found extension: $EXT_DIR"
echo "Found bundle:    $BUNDLE"
echo "Found host JS:   $EXT_HOST"
echo "Size:            $(du -h "$BUNDLE" | cut -f1)"

if [[ ! -f "$BUNDLE.bak" ]]; then
    cp "$BUNDLE" "$BUNDLE.bak"
    echo "Backup created:  $BUNDLE.bak"
else
    echo "Backup exists:   $BUNDLE.bak"
fi

if [[ ! -f "$EXT_HOST.bak" ]]; then
    cp "$EXT_HOST" "$EXT_HOST.bak"
    echo "Backup created:  $EXT_HOST.bak"
else
    echo "Backup exists:   $EXT_HOST.bak"
fi

PATCHED=0

replace_all() {
    local old="$1"
    local new="$2"
    local label="$3"

    python3 - "$BUNDLE" "$old" "$new" "$label" <<'PY'
from pathlib import Path
import sys

bundle_path = Path(sys.argv[1])
old = sys.argv[2]
new = sys.argv[3]
label = sys.argv[4]

text = bundle_path.read_text()
count = text.count(old)
if count == 0:
    print(f"{label}: skipped")
    raise SystemExit(1)

bundle_path.write_text(text.replace(old, new))
print(f"{label}: applied ({count} replacements)")
PY
}

replace_all_in_file() {
    local file_path="$1"
    local old="$2"
    local new="$3"
    local label="$4"

    python3 - "$file_path" "$old" "$new" "$label" <<'PY'
from pathlib import Path
import sys

bundle_path = Path(sys.argv[1])
old = sys.argv[2]
new = sys.argv[3]
label = sys.argv[4]

text = bundle_path.read_text()
count = text.count(old)
if count == 0:
    print(f"{label}: skipped")
    raise SystemExit(1)

bundle_path.write_text(text.replace(old, new))
print(f"{label}: applied ({count} replacements)")
PY
}

echo ""
echo "Checking for known Codex CPU hotspots"
echo "============================================"

if replace_all \
    'pp={numStars:1900,minStars:700,starsPerMegaPixel:900,baseTrailLength:2,maxTrailLength:22,speedBase:1,speedWarpMultiplier:38,clearAlphaWarpMultiplier:.8,warpEasing:.06,warpAlphaDamp:.35,idleMaxFps:20,activeMaxFps:60,unfocusedFpsMultiplier:.6' \
    'pp={numStars:200,minStars:100,starsPerMegaPixel:100,baseTrailLength:2,maxTrailLength:22,speedBase:1,speedWarpMultiplier:38,clearAlphaWarpMultiplier:.8,warpEasing:.06,warpAlphaDamp:.35,idleMaxFps:5,activeMaxFps:15,unfocusedFpsMultiplier:.1' \
    'PATCH 1 legacy starfield'; then
    PATCHED=$((PATCHED + 1))
fi

if replace_all \
    'oe?le=0:i&&!a&&(le=1e3)' \
    'oe?le=1e3:i&&!a&&(le=1e3)' \
    'PATCH 2 legacy interval'; then
    PATCHED=$((PATCHED + 1))
fi

if replace_all \
    'm.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`,`class`,`hidden`,`aria-hidden`]})' \
    'm.observe(document.body,{childList:!0,subtree:!1,attributes:!0,attributeFilter:[`style`,`class`,`hidden`,`aria-hidden`]})' \
    'PATCH 3 hotkey observer'; then
    PATCHED=$((PATCHED + 1))
fi

if replace_all \
    'se?ue=0:i&&!a&&(ue=1e3)' \
    'se?ue=1e3:i&&!a&&(ue=1e3)' \
    'PATCH 4 prerelease exec interval'; then
    PATCHED=$((PATCHED + 1))
fi

if replace_all \
    'if(document.hidden)return;if(n-T.current>=e-1){' \
    'if(document.hidden){w.current=null;return}if(n-T.current>=e-1){' \
    'PATCH 5 sign-in hidden loop'; then
    PATCHED=$((PATCHED + 1))
fi

if replace_all \
    'let n=()=>{document.hidden||(T.current=0)};' \
    'let n=()=>{document.hidden||(T.current=0,w.current==null&&(w.current=window.requestAnimationFrame(t)))};' \
    'PATCH 6 sign-in resume'; then
    PATCHED=$((PATCHED + 1))
fi

if replace_all_in_file \
    "$EXT_HOST" \
    '"open-in-targets":async()=>{throw new Error("open-in-target not supported in extension")},"set-preferred-app":async()=>{throw new Error("open-in-target not supported in extension")}' \
    '"open-in-targets":async()=>({preferredTarget:null,availableTargets:[],targets:[]}),"set-preferred-app":async()=>({success:!1})' \
    'PATCH 7 open target handler'; then
    PATCHED=$((PATCHED + 1))
fi

echo ""
echo "============================================"
echo "  $PATCHED patches applied"
echo "============================================"
echo ""
echo "Next: Reload VS Code"
echo "  Cmd+Shift+P -> 'Developer: Reload Window'"
echo ""
echo "To restore original:"
echo "  cp \"$BUNDLE.bak\" \"$BUNDLE\""
echo "  cp \"$EXT_HOST.bak\" \"$EXT_HOST\""

What steps can reproduce the bug?

Use inside vscode and open top. A Code Helper process which is the codex renderer uses 100% of a cpu on M4.

What is the expected behavior?

0% usage on idle

Additional information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗