Skip to content

Fix OHOS deadlock when release() and OnSurfaceDestroyedCB race for the same mutex. - #3522

Merged
shlzxjp merged 2 commits into
mainfrom
bugfix/markffan_ohos_deadlock
Jun 22, 2026
Merged

Fix OHOS deadlock when release() and OnSurfaceDestroyedCB race for the same mutex.#3522
shlzxjp merged 2 commits into
mainfrom
bugfix/markffan_ohos_deadlock

Conversation

@CodeJhF

@CodeJhF CodeJhF commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Problem

Fixes #3438

On OHOS platform, a deadlock can occur when release() and OnSurfaceDestroyedCB race for the same mutex in JPAGView / JPAGImageView:

  1. Thread A calls release() → acquires lockeranimator->cancel() may wait for the animation thread
  2. Thread B (XComponent callback thread) calls OnSurfaceDestroyedCB → finds listener in XComponentListeners → calls onSurfaceDestroyed() → tries to acquire locker → deadlock

Fix

Call XComponentHandler::RemoveListener(id) at the very beginning of release(), before acquiring the mutex. This disconnects the view from XComponent callbacks so the callback thread can no longer reach the mutex, eliminating the deadlock.

The double-remove is safe: RemoveListener returns false harmlessly if the key is already gone (the napi_wrap finalizer also calls RemoveListener later during GC).

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.10%. Comparing base (1151b28) to head (53cdfde).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3522      +/-   ##
==========================================
+ Coverage   81.06%   81.10%   +0.04%     
==========================================
  Files         626      626              
  Lines       71226    71226              
  Branches    20826    20826              
==========================================
+ Hits        57737    57770      +33     
+ Misses       9352     9344       -8     
+ Partials     4137     4112      -25     

☔ 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.

@shlzxjp
shlzxjp merged commit f5bbbc7 into main Jun 22, 2026
8 checks passed
@shlzxjp
shlzxjp deleted the bugfix/markffan_ohos_deadlock branch June 22, 2026 12:26
CodeJhF added a commit that referenced this pull request Jun 23, 2026
CodeJhF added a commit that referenced this pull request Jun 23, 2026
CodeJhF added a commit that referenced this pull request Jun 23, 2026
CodeJhF added a commit that referenced this pull request Jun 23, 2026
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.

使用PAG 4.4.29版本 线上发生崩溃

3 participants