Repository navigation
fix(darwin): reopen 处理函数的 panic 交给 fault handler - #20
Merged
Merged
Conversation
deliverApplicationReopen recovered a panic from the application's reopen handler but only wrote it to the diagnostic stream as platform/reopen-panic and to stderr, so a handler installed with app.SetFaultHandler never saw it, unlike a panic at every other native boundary. It now goes through platform.ReportFault as "darwin: application reopen", which delivers it to the application's handler and, while the stream is listening, as app/fault with the stack. The platform/reopen-panic event is removed so one panic is not reported twice.
23 of 26 tasks
21 of 24 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联:1lck/Lithe-IDEA#1949(panic 全部进日志),配套 1lck/Lithe-IDEA#1955;上游 PR vivaui#288(同一提交,基于上游 main)。
问题
macOS 的
deliverApplicationReopen恢复应用 reopen 处理函数的 panic 后,只写了诊断流的platform/reopen-panic和 stderr,没有调用platform.ReportFault。因此app.SetFaultHandler装的处理函数收不到这次 panic。Lithe 的统一日志就是靠这个处理函数记录app.runtime.panic_interrupted的,所以这一处 panic 不会进 Lithe 日志。其他原生边界(AppKit 视图回调、剪贴板回调、Windows 窗口过程、COM 方法、钩子)都已经走ReportFault。改动
internal/platform/darwin/reopen_darwin.go:recover 后调用platform.ReportFault("darwin: application reopen", value)。应用的 fault handler 能收到消息和发生 panic 时的栈;诊断流在监听时会收到app/fault(带where和stack)。原生回退(handled = false)和 stderr 输出不变。platform/reopen-panic事件(代码和docs/diagnostics.md中的一行),避免同一次 panic 报两遍。TestApplicationReopenPanicReachesTheFaultHandler,检查Where、Message和非空栈。其余 recover 点的排查
internal/platform下其余recover()都已调用platform.ReportFault,或者不是应用故障:runStateFor丢弃窗口释放后迟到的回调;catchJS把 JS 异常作为 error 返回;fault 路径自身的保护。internal/diag中的 recover 是诊断流自身的保护;cmd/viva/vet.go是命令行工具。验证
go test ./internal/platform/darwin ./internal/platform ./internal/diag ./app ./diagnostics:macOS arm64 在 fork main(4829f2b)和上游 main(f465bad)两个基线上都通过。Lithe 的
go.mod固定版本由团队按流程升级,本 PR 不涉及。