Skip to content

Crash when moving email to trash#1336

Merged
sosnovsky merged 4 commits intomasterfrom
feature/issue-1076
Jan 29, 2022
Merged

Crash when moving email to trash#1336
sosnovsky merged 4 commits intomasterfrom
feature/issue-1076

Conversation

@ivan-ushakov
Copy link
Contributor

@ivan-ushakov ivan-ushakov commented Jan 25, 2022

close #1076


Tests (delete all except exactly one):

  • Does not need tests (refactor only, docs or internal changes)

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities
  • is documented clearly and usefully, or doesn't need documentation

@ivan-ushakov ivan-ushakov requested a review from tomholub January 25, 2022 19:10
@tomholub tomholub removed their request for review January 25, 2022 19:13
state = .fetched(.byNumber(total: newTotalNumber))
tableNode.deleteRows(at: [IndexPath(row: index, section: 0)], with: .left)
do {
try ObjcException.catch {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please explain how is this fix related to the crash fix?

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there is an issue related to the index of the row that we try to update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As @tomholub said, we want to avoid having crash here. Even if issue is still here, we should not crash.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have an issue to solve the root cause of the crash?

Copy link
Collaborator

Choose a reason for hiding this comment

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

absolutely. Let's solve it in this PR as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since all UI is async with Texture, I guess that using message index is unsafe. We should move to message ID, as this is the only way to know that message we want to delete is the same message.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would suggest to investigate root cause of the issue.

Also if there was only one message before moving to trash we need to update whole state of the controller.

tableNode.deleteRows(at: [IndexPath(row: index, section: 0)], with: .left)
do {
try ObjcException.catch {
self.tableNode.deleteRows(at: [IndexPath(row: index, section: 0)], with: .left)
Copy link
Contributor

Choose a reason for hiding this comment

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

Data source for table node should be updated with correct amount of inboxInput then reload should be performed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Data source is updated above:

inboxInput.remove(at: index)

We could reload table node with reloadData(), but crash means that we are in invalid state. We could move from index to some kind of message ID.

But I guess that this PR is more about handling Objc exceptions in Swift.

Copy link
Collaborator

@tomholub tomholub Jan 26, 2022

Choose a reason for hiding this comment

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

While originally it was indeed primaryli about handling of ObjC exceptions, that was in part because we didn't know any better.

If the actual root cause of this exception can be fixed, that is even better and more appropriate. Both should be done. We didn't know that, so we just focused on handling, but Anton has experience with Texture specifically to notice that this is something we should be able to fix directly as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's something more specific than just updating data source, as this crash happens very rarely.
Implementing ObjC exception handling should help us to find root cause of this issue.

May be switching from index to message id (as @ivan-ushakov proposed) will fix this crash, but we can't be 100% sure as currently we're not able to reproduce this issue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If the goal is to collect more information about the crash, I suppose we should have it show a modal similar to other crash scenarios? Then some user may take a screenshot and send it to us for debugging.

As currently, it will just be logged then forgotten.

sosnovsky
sosnovsky previously approved these changes Jan 27, 2022
Copy link
Collaborator

@sosnovsky sosnovsky left a comment

Choose a reason for hiding this comment

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

I think it's a good solution for now - app won't crash if this issue occurs again and users will get alert with error message.

@ivan-ushakov
Copy link
Contributor Author

@Kharchevskyi are you agree with current approach? We will try to track down the cause of the crash with that alerts and also prevent unhandled exception to crash app.

@Kharchevskyi
Copy link
Contributor

@ivan-ushakov sure, no objections 👍

@sosnovsky sosnovsky merged commit a63f5e8 into master Jan 29, 2022
@sosnovsky sosnovsky deleted the feature/issue-1076 branch January 29, 2022 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crash when moving email to trash

4 participants