Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(macOS): race conditions around WKURLSchemeTask #1484

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

alexmoon
Copy link
Contributor

@alexmoon alexmoon commented Feb 10, 2025

Fixes two issues which could cause race conditions when navigating between pages while custom protocol requests are in progress on macOS and iOS:

  • The obc2/catch-all feature turns all Objective-C exceptions into panics, preventing obc2::exception::catch(...) from working.
  • The webview and task objects passed to start_task were not retained, leading to use-after-free issues in the responder.
  • WryWebView::remove_custom_task_key is called from both stop_task and response which may be in different threads, so custom_protocol_task_ids needs to be protected by a Mutex.

Closes #1189

@alexmoon alexmoon requested a review from a team as a code owner February 10, 2025 20:40
@alexmoon alexmoon force-pushed the wkurlschemetask-crash branch 2 times, most recently from 8f7644e to 2139170 Compare February 10, 2025 20:42
Copy link
Contributor

github-actions bot commented Feb 10, 2025

Package Changes Through 210a651

There are 1 changes which include wry with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
wry 0.48.1 0.49.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@alexmoon alexmoon force-pushed the wkurlschemetask-crash branch from 2139170 to 89b2b5c Compare February 10, 2025 21:04
Fixes two issues which could cause race conditions when navigating between pages while custom protocol requests are in progress on macOS and iOS:
- The `obc2/catch-all` feature turns all Objective-C exceptions into panics, preventing `obc2::exception::catch(...)` from working.
- The `webview` and `task` objects passed to `start_task` were not retained, leading to use-after-free issues in the `responder`.
- `WryWebView::remove_custom_task_key` is called from both `stop_task` and `response` which may be in different threads, so `custom_protocol_task_ids` needs to be protected by a `Mutex`.

Closes tauri-apps#1189
@alexmoon alexmoon force-pushed the wkurlschemetask-crash branch from 89b2b5c to 210a651 Compare February 10, 2025 21:05
@Brendonovich
Copy link
Member

For us, this PR fixes the non-fatal 'unintialized instance variable' panics we've been getting. We're still getting crashes from different places but this is helpful.

Copy link
Contributor

@pewsheen pewsheen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pewsheen pewsheen merged commit 0395df5 into tauri-apps:dev Feb 21, 2025
13 checks passed
@alexmoon
Copy link
Contributor Author

Btw, if we can ensure task lives through the responder, I think we could also remove check_task_is_valid as well.

Yes, I think those checks are likely superfluous now, since the task is retained for the lifetime of the responder. I didn't want to risk introducing a different bug, so I left them in.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[macOS] APP crash when a web custom protocol request is aborted before or during response
3 participants