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(stickers): fix crash in async task + clean up + set bought status #12676

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

jrainville
Copy link
Member

@jrainville jrainville commented Nov 9, 2023

Fixes #12664

  1. The issue was that the async task was badly made. It could return false instead of a tuple, so it made the app crashed.
    I fixed it by removing that condition, since I we don't actually care if the pack we are installing is in the cache. Worst case, status-go will return an error and we can handle it. In the better case, it was just a weird problem with the cache and since it exists in the model, it probably exists in the backend, so it would go through anyway. That issue was very random for me and I could trigger it only once.

  2. Another issue I found was that when buying a pack, we set the installed property in the model, but not bought, so if you uninstall the pack, it looks like you didn't buy it. That's fixed.

  3. Finally, I found that we called obtainMarketStickerPacks twice on app start. I fixed it by only using the one from the front-end, since it's the one that reacts to the online status changing.
    In an ideal world, that should all be handled by the backend, but it works from the frontend and the whole sticker service is messy, so it's not worth it refactoring it all just for that.

The rest of the changes are just clean ups

@@ -122,8 +122,11 @@ QtObject:
self.packs.apply(proc(it: var StickerPackView) =
if it.pack.id == packId:
it.installed = installed
if installed:
it.bought = true
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix for the bought status (problem 2 in the description)

@@ -68,9 +69,7 @@ const obtainMarketStickerPacksTask: Task = proc(argEncoded: string) {.gcsafe, ni

const installStickerPackTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[InstallStickerPackTaskArg](argEncoded)
if not arg.hasKey:
arg.finish(false)
return
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix for the crash (problem 1)

@@ -174,10 +174,6 @@ QtObject:
error "Error reverting sticker transaction", message = getCurrentExceptionMsg()

proc init*(self: Service) =
# TODO redo the connect check when the network is refactored
# if self.status.network.isConnected:
self.obtainMarketStickerPacks() # TODO: rename this to obtain sticker market items
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the fix for the double obtainMarketStickerPacks calls (problem 3)

@status-im-auto
Copy link
Member

status-im-auto commented Nov 9, 2023

Jenkins Builds

Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ ad26389 #1 2023-11-09 20:42:31 ~5 min tests/nim 📄log
✔️ ad26389 #1 2023-11-09 20:44:11 ~7 min macos/aarch64 🍎dmg
✔️ ad26389 #1 2023-11-09 20:48:39 ~11 min tests/ui 📄log
✔️ ad26389 #1 2023-11-09 20:50:13 ~13 min macos/x86_64 🍎dmg
✔️ ad26389 #1 2023-11-09 20:52:28 ~15 min linux/x86_64 📦tgz
✔️ ad26389 #1 2023-11-09 21:03:40 ~26 min windows/x86_64 💿exe
✔️ ad26389 #1 2023-11-09 21:09:01 ~31 min tests/e2e 📄log

Copy link
Contributor

@MishkaRogachev MishkaRogachev left a comment

Choose a reason for hiding this comment

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

Great!

Copy link
Contributor

@igor-sirotin igor-sirotin left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

Comment on lines 406 to +413
if installedPack.installed:
if self.marketStickerPacks.hasKey(installedPack.packId):
self.marketStickerPacks[installedPack.packId].status = StickerPackStatus.Installed
self.events.emit(SIGNAL_STICKER_PACK_INSTALLED, StickerPackInstalledArgs(
packId: installedPack.packId
))
else:
error "Sticker pack did not get installed", packId = installedPack.packId
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd appreciate quick return with inverted condition, but this is a minor thing ofc 🙂

    if not installedPack.installed:
      error "Sticker pack did not get installed", packId = installedPack.packId
      return

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I agree, but also, I'm lazy and the stickers service is pretty messed up, so eff it, I'll merge

@jrainville jrainville merged commit cf74fc2 into master Nov 13, 2023
8 of 9 checks passed
@jrainville jrainville deleted the fix/sticker-crash branch November 13, 2023 18:53
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 try to install uninstalled stickers pack
4 participants