Worker resourceLimits are not enforced while DevTools has the Debugger domain enabled
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- cpp
- 领域
- backend, mobile-dev
调研方向
Start in WorkerWrapper::OnNearHeapLimit and PrepareV8Runtime, then trace how the worker inspector session enables Debugger and how V8Debugger::enable and disable manage heap-limit callbacks. Reproduce with a debug build and a worker using resourceLimits; check that the parent receives the heap-limit error and the worker terminates after any intended debugger pause or resume.
由索引模型根据 Issue 内容生成。
描述
Summary
In a debug build, once a DevTools session enables the Debugger domain on a worker target, that worker's resourceLimits stop being enforced and the parent never receives the heap-limit error.
Why
WorkerWrapper::OnNearHeapLimit is registered with AddNearHeapLimitCallback in PrepareV8Runtime. It reports ERR_WORKER_OUT_OF_MEMORY to the parent and terminates the worker. V8 only invokes the most recently added near-heap-limit callback (Heap::InvokeNearHeapLimitCallback calls near_heap_limit_callbacks_.back(), src/heap/heap.cc). V8Debugger::enable adds its own callback (src/inspector/v8-debugger.cc), which shadows the worker's for as long as the Debugger domain stays enabled. That callback:
- schedules an OOM break (
BreakReason::kOOM), and - returns
HeapLimitForDebugging(initial_heap_limit), which raises the limit well past the configuredmaxOldGenerationSizeMb.
So while a debugger is attached to the worker, the worker either pauses on OOM in DevTools or keeps running above its cap. Either way OnNearHeapLimit never runs: the parent gets no error event, terminate/exit never follow, and code that relies on resourceLimits to contain a runaway worker behaves differently under the debugger than without it. Detaching restores the worker's callback (V8Debugger::disable removes the debugger's).
Release builds are unaffected (no inspector), and so are debug builds with no DevTools session, or with one that never enables Debugger on the worker target.
Expected
Pausing on OOM while debugging is reasonable and matches Chrome. But after the user resumes (or if the debugger's raised limit is also exhausted), the worker should still be reported and terminated as it is without a debugger. Possible directions:
- Re-register
OnNearHeapLimitafter the worker's inspector session enablesDebugger, so it stays last, and decide explicitly whether to break first. - Or chain: keep the debugger's break, but have the worker's handler run on resume, or once the debug allowance is exhausted.
Repro (sketch)
- Debug build of an app with a worker created with
resourceLimits: { maxOldGenerationSizeMb: 16 }whose script allocates until it runs out of memory. - Without DevTools: the parent gets the heap-limit
error, and the worker ends. - Attach Chrome DevTools to the worker target (which enables
Debugger) and rerun: noerrorreaches the parent. The worker pauses on OOM, or, after resuming, keeps allocating past 16 MB.
Found while reviewing #2070.
- 主要语言
- C++
- 星标
- 565
- 派生
- 147
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 27
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NativeScript/android 的其他 Issue
-
improvement
难度 5/5 一周以上 新手友好度 35/100
NativeScript/android#2100 ·
维护者通常 1 天内回复
-
ErrorReportActivity draws under the status bar on targetSdk 35 (forced edge-to-edge)可能已有人在做 @aleclarson 于 48 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 76/100
NativeScript/android#2053 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 38/100
NativeScript/android#2039 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
NativeScript/android#2024 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 20/100
NativeScript/android#2020 ·
维护者通常 1 天内回复
查看 NativeScript/android 的全部 Issue
相似的 Issue
-
难度 1/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
phantoslayer21/wronggpu#275 ·
维护者通常 1 天内回复
-
bug good first issue
难度 2/5 1-3 小时 新手友好度 75/100
ReyeMe/SaturnRingLib#155 ·
-
bug
难度 2/5 1-3 小时 新手友好度 62/100
Nheko-Reborn/nheko#2092 ·
-
难度 1/5 1-3 小时 新手友好度 78/100
isocpp/CppCoreGuidelines#2345 ·