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 issue preventing users from change profile picture #18132

Merged
merged 2 commits into from
Mar 15, 2022

Conversation

guarani
Copy link
Contributor

@guarani guarani commented Mar 14, 2022

This PR is a workaround to fix an issue where the app froze and didn't show device photos when the user attempted to set their profile photo.

It also resolves a related issue where the app was opening different albums when the user attempts to change their profile photo (now the "Recents" album will always be opened when editing profile photos).

The app was freezing (and not showing device photos) because in code, we are not requesting permissions before calling into the PHPhotoLibrary.shared().register() function. This function call happened when the app filtered only for "selfie" photos, so eliminating that filter worked around the bug.

To fix the root cause involves calling requestAuthorization(for:handler:) before applying the filter. (There was recent work, see PR here, that appears to be related to this.)

My plan is to create a separate WPMediaPicker issue and follow up on that separately, after shipping this workaround.

I have no preference between the app opening the "Selfies" album or the "Recents" album, so I don't think this change has any negative consequences from a user's perspective (let me know if you think otherwise).

To test

The app should now always open the "Recents" album when changing the user's profile picture. Test each of the following scenarios and look for any issues.

- [ ] Fresh install, change profile photo during account creation (sign-up)
- [ ] Fresh install, change profile photo after login
- [ ] Fresh install, add media via My Site → Media
- [ ] Fresh install, log in, change profile photo, add media via My Site → Media
- [ ] Fresh install, log in, change profile photo, add media via image block within the block editor
- [ ] Fresh install, log in, change profile photo, change site icon (ensure it shows both media library photos **and** device photos) 
- [ ] Without reinstalling, try any combination of the above and look out for any issues

Regression Notes

  1. Potential unintended areas of impact

The media picker is used in many places within the app and all . The test cases above include all known scenarios affected by the bug as well as scenarios where I checked for regressions

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

I relied on manual tests as specified in the above test plan.

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

I don't think adding automated tests here is feasible. Unless we mocked PHPhotoLibrary, the test would have a large external dependency. I think there's room for a unit test inside of the WPMediaPicker library, which we might be able to do once we address the root cause of this issue in a separate PR.

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.

This bug fix works around a Photo Library permissions by opening the album selector instead of the "self-portraits" album.
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 14, 2022

You can test the Jetpack changes on this Pull Request by downloading it from AppCenter here with build number: pr18132-8f2d076. IPA is available here. If you need access to this, you can ask a maintainer to add you.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 14, 2022

You can test the WordPress changes on this Pull Request by downloading it from AppCenter here with build number: pr18132-8f2d076. IPA is available here. If you need access to this, you can ask a maintainer to add you.

@guarani
Copy link
Contributor Author

guarani commented Mar 14, 2022

Tested using build pr18132-0525342:

  • Fresh install, change profile photo during account creation (sign-up)
  • Fresh install, change profile photo after login
  • Fresh install, add media via My Site → Media
  • Fresh install, log in, change profile photo, add media via My Site → Media
  • Fresh install, log in, change profile photo, add media via image block within the block editor
  • Fresh install, log in, change profile photo, change site icon (ensure it shows both media library photos and device photos)
  • Without reinstalling, try any combination of the above and look out for any issues

@peril-wordpress-mobile
Copy link

Warnings
⚠️

This PR contains changes to RELEASE_NOTES.txt.
Note that these changes won't affect the final version of the release notes as this version is in code freeze.
Please, get in touch with a release manager if you want to update the final release notes.

Generated by 🚫 dangerJS

@guarani guarani marked this pull request as ready for review March 14, 2022 23:06
@guarani guarani requested a review from momo-ozawa March 14, 2022 23:08
@guarani
Copy link
Contributor Author

guarani commented Mar 14, 2022

⚠️ This PR contains changes to RELEASE_NOTES.txt. Note that these changes won't affect the final version of the release notes as this version is in code freeze. Please, get in touch with a release manager if you want to update the final release notes.

The release notes can be left out since I don't think it's essential that they go into this release 👍
cc @mokagio

Copy link
Contributor

@momo-ozawa momo-ozawa left a comment

Choose a reason for hiding this comment

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

Tested the flows below. Works as described!

  • Fresh install, change profile photo during account creation (sign-up)
  • Fresh install, change profile photo after login
  • Fresh install, add media via My Site → Media (Opens albums w recents at the top)
  • Fresh install, log in, change profile photo, add media via My Site → Media
  • Fresh install, log in, change profile photo, add media via image block within the block editor
  • Fresh install, log in, change profile photo, change site icon (ensure it shows both media library photos and device photos)
  • Without reinstalling, try any combination of the above and look out for any issues

@mokagio mokagio added this to the 19.4 ❄️ milestone Mar 15, 2022
@mokagio
Copy link
Contributor

mokagio commented Mar 15, 2022

Thank you @guarani and @momo-ozawa 🙌

I'm going to take over merging this so we can ship a new beta today.

@mokagio mokagio merged commit 422a490 into release/19.4 Mar 15, 2022
@mokagio mokagio deleted the fix/unable-change-profile-photo branch March 15, 2022 03:34
@mokagio
Copy link
Contributor

mokagio commented Mar 15, 2022

@guarani this has been bundled as part of 19.4 beta 2 (19.4.0.2).

Thanks for your work 🙌

@guarani
Copy link
Contributor Author

guarani commented Mar 15, 2022

Thank you @momo-ozawa and @mokagio!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants