-
Notifications
You must be signed in to change notification settings - Fork 356
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
Investigate crash in DiffableDataSource #7150
Conversation
a1267a3
to
70b7f8c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way we can unit test concurrent updates? Spawn two queues, both thrashing their own updates to the data source?
Reviewable status: 0 of 6 files reviewed, 1 unresolved discussion (waiting on @mojganii)
ios/MullvadVPN/Coordinators/CustomLists/AddLocationsDataSource.swift
line 13 at r1 (raw file):
import MullvadTypes import UIKit
How did this file ever work without having these imports?
Also, are we using Combine here? I can't identify anything Combine specific in the changes here, and I was under the impression we were not using Combine anywhere in our code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The crash seems to be fixed! I have found two other things though:
-
When first showing the location view, the selected location is not centered on screen.
-
When selecting items between custom list and all locations, the snapshot state is sometimes lost. I believe this is related to not letting the
LocationNode
tree be the one source of truth. When toggling and updating selection the snapshot keeps a working state that doesn't reflect the node tree. It may be possible to make it work this way, but I doubt it will be completely reliable. What keeps track of expanded status is theshowsChildren
attribute on the node, but right now we don't update expanded status when toggling cells visible, which is a miss/bug from the original implementation. We should fix this and explicitly reapply the expanded status on the whole data set when data is reloaded (when creating snapshot items somewhere insetRelays
). Ie. we only look at the node tree for data/structure and recreate the whole snapshot based on that.
Reviewed 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pinkisemils)
ios/MullvadVPN/Coordinators/CustomLists/AddLocationsDataSource.swift
line 13 at r1 (raw file):
Previously, pinkisemils (Emīls Piņķis) wrote…
How did this file ever work without having these imports?
Also, are we using Combine here? I can't identify anything Combine specific in the changes here, and I was under the impression we were not using Combine anywhere in our code.
They have been duplicated and a copy can be found a few lines below. This part should be removed.
70b7f8c
to
0b79793
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pinkisemils)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 6 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pinkisemils)
0b79793
to
4cf4ca5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 3 of 9 files reviewed, 1 unresolved discussion (waiting on @buggmagnet and @rablador)
ios/MullvadVPN/Coordinators/CustomLists/AddLocationsDataSource.swift
line 13 at r1 (raw file):
Previously, rablador (Jon Petersson) wrote…
They have been duplicated and a copy can be found a few lines below. This part should be removed.
Yeah, this duplication should be removed.
4cf4ca5
to
66c756b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rablador it seems my recent changes will solve the problem you've mentioned above. just we need to add some more uint test for that, which I'll do that in a bit. let me know if you found any new issue with that.
for checking and simulating concurrency issue you can get help from this snippet code :
let concurrentQueue = DispatchQueue(label: "LocationDataSource.concurrentQueue", attributes: .concurrent)
let letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
let numberOfConcurrentTasks = 1000
let maxWordLength = 100
for _ in 0 ..< numberOfConcurrentTasks {
concurrentQueue.async {
let randomText = String((0 ..< maxWordLength).compactMap { _ in
letters.randomElement()!
})
if (0..<maxWordLength).randomElement()! % 2 == 0 {
self.dataSource?.setRelays(relaysWithLocation, selectedRelays: self.selectedRelays)
} else {
self.dataSource?.filterRelays(by: randomText)
}
}
}
Reviewable status: 1 of 9 files reviewed, 1 unresolved discussion (waiting on @buggmagnet, @pinkisemils, and @rablador)
ios/MullvadVPN/Coordinators/CustomLists/AddLocationsDataSource.swift
line 13 at r1 (raw file):
Previously, pinkisemils (Emīls Piņķis) wrote…
Yeah, this duplication should be removed.
that was my mistake. it's removed.
66c756b
to
c40cf8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 6 files at r3, 8 of 8 files at r4, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @mojganii and @pinkisemils)
ios/MullvadVPN/View controllers/SelectLocation/LocationDiffableDataSourceProtocol.swift
line 42 at r4 (raw file):
} func toggledItems(for cell: LocationCell, completion: (() -> Void)? = nil) {
Since this function no longer returns anything we should call it toggleItems
instead.
ios/MullvadVPN/View controllers/SelectLocation/LocationViewControllerWrapper.swift
line 114 at r4 (raw file):
setUpSegmentedControl() addSubviews() entryLocationViewController.flatMap {
Although nifty we decided some time ago that we should not use flatMap
in this way.
c40cf8d
to
6c03bd4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 4 files at r5, all commit messages.
Dismissed @pinkisemils from a discussion.
Reviewable status: complete! all files reviewed, all discussions resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved
ios/MullvadVPN/View controllers/SelectLocation/LocationDiffableDataSourceProtocol.swift
line 42 at r4 (raw file):
Previously, rablador (Jon Petersson) wrote…
Since this function no longer returns anything we should call it
toggleItems
instead.
Done.
ios/MullvadVPN/View controllers/SelectLocation/LocationViewControllerWrapper.swift
line 114 at r4 (raw file):
Previously, rablador (Jon Petersson) wrote…
Although nifty we decided some time ago that we should not use
flatMap
in this way.
Done.
6c03bd4
to
0c833d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pinkisemils Unit testing for this will be addressed in a separate task. Here is the link: Testing Location DataSource for Stability
Reviewable status: 8 of 9 files reviewed, all discussions resolved (waiting on @rablador)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r6, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 8 files at r4, 3 of 4 files at r5, 1 of 1 files at r6, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved
This PR fixes the carsh we have on UITableViewDiffableDataSource.
This change is