Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: alerts could freeze the application #1437

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dpogue
Copy link
Member

@dpogue dpogue commented May 28, 2024

Platforms affected

iOS

Motivation and Context

Closes GH-1120.
Closes GH-1121.
Closes GH-1429.

Description

In cases where the system was presenting something on the screen (such as a permission prompt, or an undo dialog) or in cases where the CDVViewController was not the root view controller (such as in a tabbed navigator), trying to show any dialogs triggered from the WebView would attempt to create an alert on the root view controller and get the view hierarchy into a bad state.

Now, we only try to display alerts on the CDVViewController that owns the WebView. This means that alerts can potentially end up behind other system dialogs, but the view controller no longer freezes.

(As an aside, having access to the CDVViewController here will be helpful for some future things too...)

Testing

Tested manually by triggering an alert while a permission prompt was being displayed and confirmed that the app continued working as expected.

Checklist

  • I've run the tests to see all new and existing tests pass
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)

@dpogue dpogue added this to the 7.1.1 milestone May 28, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.22%. Comparing base (8e59e52) to head (9cb8f8d).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1437   +/-   ##
=======================================
  Coverage   80.22%   80.22%           
=======================================
  Files          16       16           
  Lines        1871     1871           
=======================================
  Hits         1501     1501           
  Misses        370      370           

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

@jcesarmobile
Copy link
Member

This will still cause issues like not allowing to stack multiple alerts or not showing them if a view controller is present (i.e. InAppBrowser or Camera).
In Dialogs plugin we have a helper function that gets the top view controller, but not sure if it could cause the freezing issue mentioned here.
https://github.com/apache/cordova-plugin-dialogs/blob/master/src/ios/CDVNotification.m#L151-L161

@dpogue dpogue modified the milestones: 7.1.1, 8.0.0 Aug 15, 2024
@dpogue dpogue marked this pull request as draft August 25, 2024 21:11
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.

CDVWebViewUIDelegate should take a CDVViewController Presenting with JS Alert() dead lock
4 participants