Skip to content

[Desktop] ResizeObserver loop causes high CPU usage (renderer process) #34289

Closed as not planned

Description

@HEXUXIU

描述

OpenCode 桌面版 v1.17.9 / v1.17.11 的 renderer 进程因 ResizeObserver loop completed with undelivered notifications. 错误持续触发,导致 CPU 占用飙升(renderer + GPU + node service 合计 ~200s CPU / 2分钟)。

复现步骤

  1. 打开 OpenCode 桌面版
  2. 正常使用一段时间
  3. 观察 CPU 占用或查看 renderer.log

影响

  • Renderer 进程 CPU 占用 ~81s(2分钟内)
  • GPU 进程 CPU 占用 ~58s
  • Node service CPU 占用 ~58s
  • 总 CPU 负载飙升至 91%

根因

UI 组件中的 ResizeObserver 回调触发了 layout 变化,导致再次触发 resize,形成无限循环。浏览器抛出 ResizeObserver loop completed with undelivered notifications。

虽然代码中(main-D_cwiNV1.js:6176)已通过正则过滤了该错误的 Sentry 上报,但没有解决根本问题。

临时修复方案

在 renderer 的 index.html 中注入
o-patch.js,用
equestAnimationFrame 对 ResizeObserver 回调做防抖:

js window.ResizeObserver = function PatchedResizeObserver(callback) { var rafId = null; var wrapped = function(entries, observer) { if (rafId !== null) return; rafId = requestAnimationFrame(function() { rafId = null; callback(entries, observer); }); }; return new OrigResizeObserver(wrapped); };

环境

  • OpenCode 版本: 1.17.9 / 1.17.11
  • 平台: Windows (Electron 42.3.3)

Activity

  1. github-actions commented on Jun 28, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. github-actions commented on Aug 28, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions