Fix: App crashes when tapping more and share button in the Reader Details screen#20490
Conversation
|
| App Name | ||
| Configuration | Release-Alpha | |
| Build Number | pr20490-b99189a | |
| Version | 22.1 | |
| Bundle ID | org.wordpress.alpha | |
| Commit | b99189a | |
| App Center Build | WPiOS - One-Offs #5452 |
|
| App Name | ||
| Configuration | Release-Alpha | |
| Build Number | pr20490-b99189a | |
| Version | 22.1 | |
| Bundle ID | com.jetpack.alpha | |
| Commit | b99189a | |
| App Center Build | jetpack-installable-builds #4481 |
… UIView or a UIBarButtonItem
015a81e to
5571dc9
Compare
Generated by 🚫 dangerJS |
guarani
left a comment
There was a problem hiding this comment.
Tested and works well! Thanks for the fix, @salimbraksa!
…iOS into fix/20487-reader-crash-when-wtapping-more-share-button
|
I find it spooky that this PR keeps failing in Moreover, there might be something dodgy down in the reporting layer, because looking at the logs we can see that the test eventually succeeds after retrying automatically I see no reason to hold merging this PR because of that. |
|
Hey @mokagio @salimbraksa , |
There were conflicts on `Podfile` and `Podfile.lock` because `release/22.1` and `trunk` both changed the Gutenberg version. As usual, I resolved them with `git checkout --theirs`, keeping the value from `trunk` under the assumption that the latest version of Gutenberg, 1.93.0-alpha2, is what `trunk` needs to work and that if the 1.92.1 hotfix hasn't already been integrated in the latest release, it will be soon and the Gutenberg team will followup with a new version update on `trunk`. There was also a conflict on the `RELEASE-NOTES.txt` that GitHub picked up with its more refined conflicts engine and that auto-merge didn't address properly but that I manually fixed. That was due to `release/22.1` adding new release note entries – which will not make it into the App Store release notes – in the 22.1 section and `trunk` having #20128 editing that section, too. #20128 was meant to land on `release/22.1` but I forgot to update the base branch after starting the code freeze 🤦♂️😭 ``` <<<<<<< release/22.1 -- Incoming Change * [**] Add a "Personalize Home Tab" button to the bottom of the Home tab that allows changing cards visibility. [#20369] * [*] [Reader] Fix an issue that was causing the app to crash when tapping the More or Share buttons in Reader Detail screen. [#20490] * [*] Block editor: Avoid empty Gallery block error [WordPress/gutenberg#49557] ======= * [**] [internal] Refactored Google SignIn implementation to not use the Google SDK [#20128] >>>>>>> trunk -- Current Change ```
| * [***] [internal] Refactor uploading photos (from the device photo, the Free Photo library, and other sources) to the WordPress Media Library. Affected areas are where you can choose a photo and upload, including the "Media" screen, adding images to a post, updating site icon, etc. [#20322] | ||
| * [**] [WordPress-only] Warns user about sites with only individual plugins not supporting core app features and offers the option to switch to the Jetpack app. [#20408] | ||
| * [**] Add a "Personalize Home Tab" button to the bottom of the Home tab that allows changing cards visibility. [#20369] | ||
| * [*] [Reader] Fix an issue that was causing the app to crash when tapping the More or Share buttons in Reader Detail screen. [#20490] |
There was a problem hiding this comment.
Notice that since this landed in the release branch after code freeze, the App Store release notes won't include it.
There were conflicts on `Podfile` and `Podfile.lock` because `release/22.1` and `trunk` both changed the Gutenberg version. As usual, I resolved them with `git checkout --theirs`, keeping the value from `trunk` under the assumption that the latest version of Gutenberg, 1.93.0-alpha2, is what `trunk` needs to work and that if the 1.92.1 hotfix hasn't already been integrated in the latest release, it will be soon and the Gutenberg team will followup with a new version update on `trunk`. There was also a conflict on the `RELEASE-NOTES.txt` that GitHub picked up with its more refined conflicts engine and that auto-merge didn't address properly but that I manually fixed. That was due to `release/22.1` adding new release note entries – which will not make it into the App Store release notes – in the 22.1 section and `trunk` having #20128 editing that section, too. #20128 was meant to land on `release/22.1` but I forgot to update the base branch after starting the code freeze 🤦♂️😭 Also, the entry about the personalize home tab had been removed on `trunk` via ec8a377. The release notes editor was notified about it, #20483 (review) ``` <<<<<<< release/22.1 -- Incoming Change * [**] Add a "Personalize Home Tab" button to the bottom of the Home tab that allows changing cards visibility. [#20369] * [*] [Reader] Fix an issue that was causing the app to crash when tapping the More or Share buttons in Reader Detail screen. [#20490] * [*] Block editor: Avoid empty Gallery block error [WordPress/gutenberg#49557] ======= * [**] [internal] Refactored Google SignIn implementation to not use the Google SDK [#20128] >>>>>>> trunk -- Current Change ```



Fixes #20487
Description
This PR fixed a bug that crashed the app when the user taps the more or share button in the Reader Details screen. This bug is only affecting iPad users.
Root Cause
This is the exact change in #20363 that caused the crash.
func barButtonItem(with image: UIImage, action: Selector) -> UIBarButtonItem { let image = image.withRenderingMode(.alwaysTemplate) - let button = UIButton(frame: CGRect(x: 0, y: 0, width: 44.0, height: image.size.height)) - button.setImage(image, for: UIControl.State()) - button.addTarget(self, action: action, for: .touchUpInside) - - return UIBarButtonItem(customView: button) + return UIBarButtonItem(image: image, style: .plain, target: self, action: action) }The code above removes usage of
UIButtonwhen creating aUIBarButtonItem, so theactionparam is now passed to aUIBarButtonIteminstead of aUIButton. But thesenderparam of the action handlers was not updated accordingly.The type of
senderparam type should beUIBarButtonIteminstead ofUIButton. The compiler didn't catch this, and I didn't either.At runtime, however, the
senderparam type wasUIBarButtonItem, which passed through several methods until it reached the following code.The
presentationController.sourceView's type isUIViewandanchor's type at runtime isUIBarButtonItem, thus the crash.Screenshots
Test Instructions
Please perform the following tests on iPhone and iPad.
Regression Notes
Double check the More and Share buttons work as expected in Reader Details and Reader Following / Discover screens.
What I did to test those areas of impact (or what existing automated tests I relied on)
Manual testing.
What automated tests I added (or what prevented me from doing so)
None.
PR submission checklist:
RELEASE-NOTES.txtif necessary.