metabolist / metatext

A free, open-source iOS Mastodon client.
https://metabolist.org/metatext
GNU General Public License v3.0
726 stars 101 forks source link

Crash when muting profile you follow #48

Closed jbalint-de closed 2 years ago

jbalint-de commented 3 years ago

Description: App crashes when muting a profile you follow

Steps to reproduce the behavior:

  1. Go to profile you follow
  2. Mute profile
  3. App crashes

Expected behavior: App shouldn't crash.

cdenesha commented 2 years ago

I looked first to see if my issue was here, and this is close.

Crash when muting profile.

Tap on any user’s profile in your feed. Mute them. Keep default options, tap Mute to save.

App immediately crashes, when you open it the Mute was successful.

It shouldn’t crash.

iPhone 13 pro, iPadOS 15.7.1, Metatext 1.5.3. Bug_type is 309

vollkorntomate commented 2 years ago

I don't know the root cause for this crash, however, I was able to reproduce it sometimes and to get some insight into what happens.

The crash happens in CollectionItemsViewModel.swift, in function viewModel(indexPath: IndexPath) -> Any:

public func viewModel(indexPath: IndexPath) -> Any {
    let item = lastUpdate.sections[indexPath.section].items[indexPath.item] // <-- items is empty, ergo: array index out of bounds for index 0
    let cachedViewModel = viewModelCache[item]
    // ...
}

I notices that when muting a profile from the profile page (and the app doesn't crash for once), none of the account's toots are shown anymore (the profile is shown, but without any posts). They only become visible again when refreshed by pulling down. This might have to do with the error, perhaps because some cache is invalidated (?) or so.