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

Scale picture of the day widget to address blank widget issue #4413

Merged
merged 2 commits into from Dec 8, 2022

Conversation

staykids
Copy link
Contributor

@staykids staykids commented Dec 2, 2022

Phabricator: https://phabricator.wikimedia.org/T321061

Notes

This PR addresses an issue where the POTD widget doesn't render an image. For whatever reason, some OS level change appears to have constrained what's possible to display in a widget's SwiftUI Image view. Previously, WidgetKit/SwiftUI seemed to be more forgiving of the dimensionality of images here.

Originally, I had the belief that unusually large image dimensions were causing the crash because the requested image required too much memory (exceeding what's allotted by WidgetKit), but it actually seems to be the case that just the dimensions themselves were what was causing issues, not necessarily the image's file size itself. For example, an image with an unusually large width regardless of file size, which may have rendered without issue before, is now simply causing the widget to blank out. Through some experimentation, resizing the image to draw within 1000x1000 pixels seems to allow the images/devices I've tested to render without blanking out. The negative of this approach though, is that depending on device and widget size, the image may appear blurrier than before (because it's not considering the device's scale).

It's worth noting, I continue to have really poor luck with the debugging WidgetKit widgets. I also have additional incomplete work that removes the Core Data dependencies to make the widget more independent (like the feature article widget), but I need to hold that work for a future PR because it's becoming more involved than I had hoped.

Test Steps

  1. Delete existing Wikipedia POTD widgets then build/install and open app.
  2. Long pressing the home screen and opening the Wikipedia widget gallery, confirm the POTD widget isn't blank.
  3. Add a POTD widget at any size. Confirm it actually renders the expected image on your home screen.
  4. Delete that POTD widget and add another at a different size.

Additionally if interested, you can try to manually use some previously problematic images that resulted in blank widgets to ensure they work with the new scaling logic. An example of a previous image that resulted in failure is the image featured here: https://en.wikipedia.org/api/rest_v1/feed/featured/2022/11/12. By adding it to the Widget asset catalog, then replacing cachedImage.staticImage, fetchedImage.image.staticImage, and UIImage(named: "PictureOfTheYear_2019") in PictureOfTheDayWidget.swift with that image, you should be able to present it in the POTD widget to confirm it renders and isn't blank.

@staykids staykids requested review from a team and mazevedofs and removed request for a team December 2, 2022 23:40
Copy link
Collaborator

@mazevedofs mazevedofs left a comment

Choose a reason for hiding this comment

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

I'm still having issues with the large widget, I'm testing on an iPhone 13 mini and an iPad 9th gen. The small and medium widgets are working well in both devices.

@staykids
Copy link
Contributor Author

staykids commented Dec 7, 2022

I'm still having issues with the large widget

Thanks for reviewing this! I'm not noticing the same on my end. A few questions:

  • To confirm - this is following the steps above of removing any existing POTD widgets before adding a large one? There seems to be some existing issue (even on main) with multiple POTD widgets not rendering, but with this branch I haven't been able to replicate an individual widget at any size not rendering.
  • Are you noticing this on device or simulator, iOS 15 or 16?
  • Does tapping the blank widget to launch the app and returning to the home screen show the picture content?
  • Are you encountering this with the current POTD image or a test one I mentioned above?

@mazevedofs
Copy link
Collaborator

  • To confirm - this is following the steps above of removing any existing POTD widgets before adding a large one? There seems to be some existing issue (even on main) with multiple POTD widgets not rendering, but with this branch I haven't been able to replicate an individual widget at any size not rendering.

Yes! I deleted the app and the widgets before running the branch and adding the new widgets.

  • Are you noticing this on device or simulator, iOS 15 or 16?

On device only:

  • iPhone 13 mini iOS 15.6
  • iPad 9th gen iPadOS 16
  • Does tapping the blank widget to launch the app and returning to the home screen show the picture content?

It opens the app on the home screen.

  • Are you encountering this with the current POTD image or a test one I mentioned above?

I tried today's (12/7) and yesterday's (6/12) pictures, I can test with the suggested images tomorrow if it's helpful

Is there something else I can try to see what is going on with my test attempts?

@mazevedofs mazevedofs merged commit 38c06b5 into main Dec 8, 2022
@mazevedofs mazevedofs deleted the widget/potd-dimensions branch December 8, 2022 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants