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 crash in Reader stream empty state views #23908

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

kean
Copy link
Contributor

@kean kean commented Dec 18, 2024

Fixes https://a8c.sentry.io/issues/6153580880:

Unable to activate constraint with anchors <NSLayoutYAxisAnchor:0x3038cdd00 "_TtGC11WordPressUI13UIHostingViewGVS_14EmptyStateViewGV7SwiftUI5LabelVS2_4TextVS2_5Image_GSqS4__VS2_9EmptyView__:0x109441680.top"> and <NSLayoutYAxisAnchor:0x30390d500 "WordPress.ReaderDiscoverHeaderView:0x1096cec00.bottom"> because they have no common ancestor.  Does the constraint or its anchors reference items in different view hierarchies?  That's illegal

I'm not sure when this happens, but I decided to keep it simple and lay it out with frames. It also fixes an issue with the bottom part of the view being not scrollable (only the header was).

Screenshot 2024-12-18 at 12 39 20 PM

I kept the nice parallax effect but, of course, you can drag from anywhere.

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-12-18.at.13.17.10.mp4

To test:

You can easily test It by replacing this:

    override func predicateForFetchRequest() -> NSPredicate {
         return NSPredicate(format: "post != NULL OR topics.@count != 0 OR sites.@count != 0")
     }

with this:

    override func predicateForFetchRequest() -> NSPredicate {
         return NSPredicate(format: "post != NULL AND topics.@count == 999 AND sites.@count != 0")
     }

or just disabling internet connection

Regression Notes

  1. Potential unintended areas of impact

  2. What I did to test those areas of impact (or what existing automated tests I relied on)

  3. What automated tests I added (or what prevented me from doing so)

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing checklist:

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

@kean kean added the Reader label Dec 18, 2024
@kean kean added this to the 25.6 ❄️ milestone Dec 18, 2024
@kean kean requested a review from crazytonyli December 18, 2024 18:17
@dangermattic
Copy link
Collaborator

dangermattic commented Dec 18, 2024

1 Warning
⚠️ This PR is assigned to the milestone 25.6 ❄️. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@kean kean force-pushed the fix/crash-reader-empty-state-view branch from 52901aa to 1a082c2 Compare December 18, 2024 18:20
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Dec 18, 2024

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr23908-4b8532f
Version25.6
Bundle IDorg.wordpress.alpha
Commit4b8532f
App Center BuildWPiOS - One-Offs #11214
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Dec 18, 2024

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr23908-4b8532f
Version25.6
Bundle IDcom.jetpack.alpha
Commit4b8532f
App Center Buildjetpack-installable-builds #10252
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Copy link
Contributor

@crazytonyli crazytonyli left a comment

Choose a reason for hiding this comment

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

The interaction is neat!

// Calculate visible part of the table view in `self.view` coordinates
let y: CGFloat = {
if let headerView = tableView.tableHeaderView {
return headerView.convert(headerView.frame, to: view).maxY
Copy link
Contributor

Choose a reason for hiding this comment

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

It probably doesn't make much difference in reality, but I think it only make sense to use bounds here, because headerView.frame is not in headerView's coordinate space?

Suggested change
return headerView.convert(headerView.frame, to: view).maxY
return headerView.convert(headerView.bounds, to: view).maxY

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I wrote it hastily, and what it currently doesn't make a whole lot of space. It should be:

return tableView.convert(headerView.frame, to: view).maxY

Convert the header view frame from the table view coordinate space (its superview) to the coordinate space of the main view.

I updated it.

@kean kean requested a review from crazytonyli December 19, 2024 15:13
@kean kean force-pushed the fix/crash-reader-empty-state-view branch from 52406f9 to 5d3f200 Compare December 19, 2024 21:18
@kean kean enabled auto-merge December 19, 2024 21:18
@kean kean disabled auto-merge December 19, 2024 21:21
@kean kean force-pushed the fix/crash-reader-empty-state-view branch from 5d3f200 to 4b8532f Compare December 19, 2024 21:22
@kean kean added this pull request to the merge queue Dec 19, 2024
Merged via the queue into trunk with commit cc26fec Dec 19, 2024
25 checks passed
@kean kean deleted the fix/crash-reader-empty-state-view branch December 19, 2024 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants