Skip to content

Fix potential crash by creating the macOS PAGView render surface on the main thread#3504

Open
leiyue123 wants to merge 6 commits into
mainfrom
bugfix/thunderllei_macos_surface
Open

Fix potential crash by creating the macOS PAGView render surface on the main thread#3504
leiyue123 wants to merge 6 commits into
mainfrom
bugfix/thunderllei_macos_surface

Conversation

@leiyue123

Copy link
Copy Markdown
Collaborator

为修复 issue #1870 的崩溃问题,将 macOS PAGView 的渲染 surface 创建放到主线程执行。

当 onCreateSurface 在非主线程被调用时(例如视图缩放或缓存释放触发的重新创建),CGLWindow 需要在主线程访问 NSView 的几何信息,否则可能崩溃。此改动参照 iOS 的既有方案,在非主线程调用时通过 dispatch_async 把 surface 创建推迟到主队列,完成后发出通知触发重绘。PAGView 改名为 PAGView.mm 以支持 C++ 互操作。

同时包含针对该实现的若干代码审查修复:统一异步通知回调方法的小写开头命名、移除 onCreateSurface 中不可达的缓存分支与冗余成员赋值、在派发异步块前对 lock 失败做空指针保护、并将首次 surface 创建移至 weakThis 赋值之后以消除构造期的时序隐患。

…cos_surface

# Conflicts:
#	src/platform/mac/PAGView.mm
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.56%. Comparing base (2eba728) to head (371a31d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3504      +/-   ##
==========================================
- Coverage   80.57%   80.56%   -0.02%     
==========================================
  Files         620      620              
  Lines       67021    67021              
  Branches    19885    19885              
==========================================
- Hits        54005    53996       -9     
- Misses       9079     9083       +4     
- Partials     3937     3942       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants