Skip to content

Fix a rare crash when opening a file downloads stats view#23310

Merged
staskus merged 1 commit intotrunkfrom
fix/23270-stats-details-supplied-item-identifiers-are-not-unique
Jun 25, 2024
Merged

Fix a rare crash when opening a file downloads stats view#23310
staskus merged 1 commit intotrunkfrom
fix/23270-stats-details-supplied-item-identifiers-are-not-unique

Conversation

@staskus
Copy link
Contributor

@staskus staskus commented Jun 5, 2024

Fixes #23270

After analysing crash reports, it can happen when filename of two files is identical. Normally, when the file is uploaded to the backend, the filename gets added a suffix ( "_1"). However, I noticed that when a file is uploaded at a different date, it gets uploaded to "2024/06/file_name" url which then skips adding a suffix. It creates conditions for a crash.

Solution

  • Add a unique identifier to stats downloads rows to ensure they are always treated as unique

To test:

I reproduced the crash manually by changing file name to be identical, and then confirming that there's no crash for file downloads details.

  1. Log into the site that has a lot of files or create a new site and upload 6+ files
  2. Open Stats -> Traffic
  3. Scroll to File Downloads
  4. Tap View More
  5. Confirm there's no crash

Regression Notes

  1. Potential unintended areas of impact

Couldn't identify

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

  2. 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)

@staskus staskus changed the title Fix/23270 stats details supplied item identifiers are not unique Fix a rare crash when opening a file downloads stats view Jun 5, 2024
@staskus staskus marked this pull request as ready for review June 5, 2024 10:54
@staskus staskus requested a review from guarani June 5, 2024 10:54
@staskus staskus modified the milestones: 25.1, Pending Jun 5, 2024
@staskus
Copy link
Contributor Author

staskus commented Jun 19, 2024

Update after #23366 is merged

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Jun 21, 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 Numberpr23310-4a3c216
Version25.1
Bundle IDorg.wordpress.alpha
Commit4a3c216
App Center BuildWPiOS - One-Offs #10220
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 Jun 21, 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 Numberpr23310-4a3c216
Version25.1
Bundle IDcom.jetpack.alpha
Commit4a3c216
App Center Buildjetpack-installable-builds #9269
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Copy link
Contributor

@kean kean left a comment

Choose a reason for hiding this comment

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

I didn't have any sites with file uploads stats, so I couldn't test, but I reviewed the code and the tests, and it looks good.

I'm approving it with one small inline comment.

One small thing to consider: in theory, downloadURL can also be not unique. In the scenarios where data doesn't have an inherent ID field, it's best to simply assign a UUID to each item and let them reload.

File Downloads data can be identical which can result in a rare duplicate diffable data source identifiers crash. Pass a unique identifier to ensure that each file downloads row is treated as unique.
@staskus
Copy link
Contributor Author

staskus commented Jun 25, 2024

One small thing to consider: in theory, downloadURL can also be not unique. In the scenarios where data doesn't have an inherent ID field, it's best to simply assign a UUID to each item and let them reload.

@kean, thanks. Yes, I think this is the safest solution rather than passing additional unnecessary data to rows which we can't ensure being unique as well.

@staskus staskus force-pushed the fix/23270-stats-details-supplied-item-identifiers-are-not-unique branch from 573b6a8 to 4a3c216 Compare June 25, 2024 06:43
@staskus staskus modified the milestones: Pending, 25.2 Jun 25, 2024
@staskus staskus enabled auto-merge (squash) June 25, 2024 06:44
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is assigned to the milestone 25.2. 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

@staskus staskus merged commit d8a1348 into trunk Jun 25, 2024
@staskus staskus deleted the fix/23270-stats-details-supplied-item-identifiers-are-not-unique branch June 25, 2024 07:05
jkmassel added a commit that referenced this pull request Jul 5, 2024
* Optimize TopTotalsCell to add rows only when the cell loads

TopTotalsCell was calling addRows on every configuration of cell which in turn created and added a hierarchy of UIStackView-based views.

Optimizing TopTotalsCell to only add rows once and then make manipulations on existing rows.

* Optimize CountriesCell to add rows only when the cell loads

* Do not track StatsTraffic tableView scrolling

* Update RELEASE-NOTES.txt

* Update TopTotalsCell to use setNeedsLayout for more efficiency

* Update CountriesCell to use setNeedsLayout for more efficiency

* Update RELEASE-NOTES

* Move additional checks for adding default rows into the extension

* Fix rare crash in GutenbergWebViewController

* Update release notes

* Remove force layout calls when setting subtitle visibility

These calls were added together with dynamic type support, however, they slow down layout process of the cell

* Make maximum content size category smaller for stats cell subtitles

* Create StatsRowsCell with default child stack view rows and ability to configure more

* Put analyticsTracker back since it's used by JetpackBanner

* JPBackground as png

* Move JPBackground to AppImage specific to the Jetpack app

* Remove Stories related files

* Remove unused site creation icons

* Reduce rppreview size

* Replace JPBackground with tiny-fied icons

* Remove custom fonts used by Kanvas

* Remove remaining Kanvas related code

* Remove Kanvas related code

* Remove StoryEditor

* Replace remaining Kanvas usages

* Remove StoriesIntroViewController

* Remove Kanvas pod

* Update rubocop.yml

* Add unique identifier to file downloads rows (#23310)

File Downloads data can be identical which can result in a rare duplicate diffable data source identifiers crash. Pass a unique identifier to ensure that each file downloads row is treated as unique.

* Support editing media metadata via XML-RPC #809 (#23316)

* Support media metadata editing for XML-RPC connected self-hosted sites

- Updated WordPressKit supports editing title, description, and caption of the media via XML-RPC
- XML-RPC API doesn't support editing alt-text

* Support editing media metadata via XMLRPC in MediaService

Media is a type of a post therefore "wp.editPost" can be used to edit media metadata. Note that alternative text cannot be edited due to lack of XML-RPC support https://core.trac.wordpress.org/ticket/58582

* Update RELEASE-NOTES.txt

* Fix warnings in MemoryCache

* Fix warnings in CachedAsyncImage

* Fix more warnings

* Remove deprecated in JetpackBrandingVisibility.enabled

* Remove AlamofireNetworkActivityIndicator (#23385)

* Merge 25.1 release finalization (#23391)

* Fix announcement card keep showing up after tapping Done (#23384)

* Update app translations – `Localizable.strings`

* Update WordPress metadata translations

* Update Jetpack metadata translations

* Bump version number

---------

Co-authored-by: David Christiandy <1299411+dvdchr@users.noreply.github.com>

* Update WordPressKit and WordPressAuthentificator setup (#23392)

* Install WordPressUI using SPM

* Remove WordPressShared from Podfile

* Add WordPressShared using SPM

* Fix WordPress compilation

* Fix WordPressKit being embeded in the wrong targets

* Disable some warnings in WordPressKit

* Remove redundant manual linker flags

* Fix WordPressKit tests

* Fix WordPressAuthentificator tests

* Remove Specta and Expecta from Podfile

* Fix WordPressAuthentificator tests by temporary disabling LoginFacadeTests

* Update WordPressAuthenticator so that it could be compliled as an ObjC module again

* Rewrite LoginFacadeTests

* Fix WordPressTests

* Add missing executable_path/../../Frameworks in the share extensions

---------

Co-authored-by: Povilas Staskus <povilas.staskus@automattic.com>
Co-authored-by: Jeremy Massel <1123407+jkmassel@users.noreply.github.com>
Co-authored-by: WordPress Mobile Bot Account <mobile+wpmobilebot@automattic.com>
Co-authored-by: David Christiandy <1299411+dvdchr@users.noreply.github.com>
jkmassel added a commit that referenced this pull request Jul 5, 2024
commit e0fd9fd
Author: Gio Lodi <gio.lodi@automattic.com>
Date:   Wed Jul 3 15:08:20 2024 +1000

    Explicitly set mac queue in Buildkite pipeline (#23402)

commit 312df0f
Author: Gio Lodi <gio.lodi@automattic.com>
Date:   Mon Jul 1 17:37:37 2024 +1000

    Bump Fastlane `xcodebuild -showBuildSettings` interval (#23403)

    This is an attempt to avoid timeouts, mostly in CI.

commit bae5a91
Author: WordPress Mobile Bot Account <mobile+wpmobilebot@automattic.com>
Date:   Thu Jun 27 09:08:50 2024 +1000

    Merge 25.1 release finalization (#23391)

    * Fix announcement card keep showing up after tapping Done (#23384)

    * Update app translations – `Localizable.strings`

    * Update WordPress metadata translations

    * Update Jetpack metadata translations

    * Bump version number

    ---------

    Co-authored-by: David Christiandy <1299411+dvdchr@users.noreply.github.com>

commit c508e4f
Author: Alex Grebenyuk <alex.grebenyuk@automattic.com>
Date:   Tue Jun 25 23:47:11 2024 -0400

    Remove AlamofireNetworkActivityIndicator (#23385)

commit 7bc34eb
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Tue Jun 25 11:00:32 2024 -0400

    Remove deprecated in JetpackBrandingVisibility.enabled

commit 9c8ff9a
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Tue Jun 25 10:58:55 2024 -0400

    Fix more warnings

commit 55e0cd4
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Tue Jun 25 10:53:34 2024 -0400

    Fix warnings in CachedAsyncImage

commit 1f78c63
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Tue Jun 25 10:51:42 2024 -0400

    Fix warnings in MemoryCache

commit 9d86b6b
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Tue Jun 25 09:06:16 2024 +0200

    Support editing media metadata via XML-RPC #809 (#23316)

    * Support media metadata editing for XML-RPC connected self-hosted sites

    - Updated WordPressKit supports editing title, description, and caption of the media via XML-RPC
    - XML-RPC API doesn't support editing alt-text

    * Support editing media metadata via XMLRPC in MediaService

    Media is a type of a post therefore "wp.editPost" can be used to edit media metadata. Note that alternative text cannot be edited due to lack of XML-RPC support https://core.trac.wordpress.org/ticket/58582

    * Update RELEASE-NOTES.txt

commit d8a1348
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Tue Jun 25 09:05:13 2024 +0200

    Add unique identifier to file downloads rows (#23310)

    File Downloads data can be identical which can result in a rare duplicate diffable data source identifiers crash. Pass a unique identifier to ensure that each file downloads row is treated as unique.

commit 09137d3
Merge: fc50d1a c88e54a
Author: Jeremy Massel <1123407+jkmassel@users.noreply.github.com>
Date:   Mon Jun 24 14:16:17 2024 -0600

    Reduce App Size – Assets (#23381)

commit fc50d1a
Merge: 2270784 32a3251
Author: Jeremy Massel <1123407+jkmassel@users.noreply.github.com>
Date:   Mon Jun 24 14:15:55 2024 -0600

    Remove Stories and Kanvas dependency (#23382)

commit 2270784
Merge: 2ee755c f76856a
Author: Jeremy Massel <1123407+jkmassel@users.noreply.github.com>
Date:   Mon Jun 24 13:50:40 2024 -0600

    Update rubocop.yml (#23383)

commit f76856a
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 15:27:29 2024 -0400

    Update rubocop.yml

commit 32a3251
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 13:52:46 2024 -0400

    Remove Kanvas pod

commit c93087b
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 13:30:10 2024 -0400

    Remove StoriesIntroViewController

commit e64e98d
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 13:25:40 2024 -0400

    Replace remaining Kanvas usages

commit 3ec3d0d
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 12:26:35 2024 -0400

    Remove StoryEditor

commit 4b66f07
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 12:17:06 2024 -0400

    Remove Kanvas related code

commit 4812e5b
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 12:13:48 2024 -0400

    Remove remaining Kanvas related code

commit f7743b6
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 12:11:30 2024 -0400

    Remove custom fonts used by Kanvas

commit c88e54a
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 10:44:12 2024 -0400

    Replace JPBackground with tiny-fied icons

commit a9d80c8
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 10:33:29 2024 -0400

    Reduce rppreview size

commit ac82126
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 10:27:29 2024 -0400

    Remove unused site creation icons

commit 5b8a5a3
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 10:21:00 2024 -0400

    Remove Stories related files

commit 6f98ffd
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 10:19:06 2024 -0400

    Move JPBackground to AppImage specific to the Jetpack app

commit dd78ad7
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Mon Jun 24 10:09:20 2024 -0400

    JPBackground as png

commit 2ee755c
Merge: 81bc1c5 3835956
Author: Alex Grebenyuk <alex.grebenyuk@automattic.com>
Date:   Fri Jun 21 10:13:38 2024 -0400

    Fix rare crash in GutenbergWebViewController (#23379)

commit 81bc1c5
Merge: 6dc78ec 465047a
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Fri Jun 21 13:30:39 2024 +0300

    Stats: Improve scrolling performance  (#22847)

commit 465047a
Merge: bc88b72 6dc78ec
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Fri Jun 21 11:00:43 2024 +0300

    Merge branch 'trunk' into task/22721-stats-traffic-improve-scrolling-performance

commit bc88b72
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Fri Jun 21 10:57:00 2024 +0300

    Put analyticsTracker back since it's used by JetpackBanner

commit 1b8bc1c
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Fri Jun 21 10:52:21 2024 +0300

    Create StatsRowsCell with default child stack view rows and ability to configure more

commit 89fd816
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Fri Jun 21 10:28:28 2024 +0300

    Make maximum content size category smaller for stats cell subtitles

commit 51992ab
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Fri Jun 21 10:28:01 2024 +0300

    Remove force layout calls when setting subtitle visibility

    These calls were added together with dynamic type support, however, they slow down layout process of the cell

commit 3835956
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Thu Jun 20 10:27:02 2024 -0400

    Update release notes

commit 26bd9b3
Author: kean <grebenyuk.alexander@gmail.com>
Date:   Thu Jun 20 10:23:16 2024 -0400

    Fix rare crash in GutenbergWebViewController

commit 7684a35
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Thu Jun 20 10:48:25 2024 +0300

    Move additional checks for adding default rows into the extension

commit 25bf46d
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Wed Jun 19 13:47:26 2024 +0300

    Update RELEASE-NOTES

commit 8884f81
Merge: 2674401 1c05916
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Wed Jun 19 13:35:52 2024 +0300

    Merge branch 'trunk' into task/22721-stats-traffic-improve-scrolling-performance

commit 2674401
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Thu Apr 11 15:57:07 2024 +0300

    Update CountriesCell to use setNeedsLayout for more efficiency

commit eb7c142
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Thu Apr 11 15:45:56 2024 +0300

    Update TopTotalsCell to use setNeedsLayout for more efficiency

commit d0af997
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Wed Apr 10 11:40:38 2024 +0300

    Update RELEASE-NOTES.txt

commit 8fb2eb4
Merge: 9252c6f d79aa28
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Wed Apr 10 10:07:24 2024 +0300

    Merge branch 'trunk' into task/22721-stats-traffic-improve-scrolling-performance

commit 9252c6f
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Mon Mar 18 17:05:19 2024 +0200

    Do not track StatsTraffic tableView scrolling

commit 9880cb7
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Mon Mar 18 17:05:02 2024 +0200

    Optimize CountriesCell to add rows only when the cell loads

commit 98d5b77
Author: Povilas Staskus <povilas.staskus@automattic.com>
Date:   Mon Mar 18 16:45:44 2024 +0200

    Optimize TopTotalsCell to add rows only when the cell loads

    TopTotalsCell was calling addRows on every configuration of cell which in turn created and added a hierarchy of UIStackView-based views.

    Optimizing TopTotalsCell to only add rows once and then make manipulations on existing rows.
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.

Stats Details: supplied item identifiers are not unique

4 participants