deltachat / deltachat-desktop

Email-based instant messaging for Desktop.
GNU General Public License v3.0
947 stars 169 forks source link

1.48.0 crashes sometimes when i try to quote-reply #4337

Open hpk42 opened 1 week ago

hpk42 commented 1 week ago

image

WofWca commented 1 week ago

Is it 100% reproducible for you? I can't reproduce.

hpk42 commented 1 week ago

No, it's not reproducible. If that rules out fixing it feel free to close. I'll file another issue if it reappears. Was the first itme i encountered it (but i am also not often quote-replying to webxdc-app messages).

On Wed, Nov 13, 2024 at 02:09 -0800, WofWca wrote:

Is it 100% reproducible for you? I can't reproduce. -- Reply to this email directly or view it on GitHub: https://github.com/deltachat/deltachat-desktop/issues/4337#issuecomment-2473068586 You are receiving this because you authored the thread.

Message ID: @.***>

WofWca commented 1 week ago

I looked through all the .slice we have in the codebase and narrowed it down to these two lines:

https://github.com/deltachat/deltachat-desktop/blob/78fef8b6b45329250c369dc23bd1c4bcd02adca5/packages/frontend/src/components/message/Message.tsx#L805

https://github.com/deltachat/deltachat-desktop/blob/a5c02433976909fe01a64f3049c96d0d101ae9d8/packages/frontend/src/components/Reactions/index.tsx#L35

They produce the same stack trace as in the screenshot you posted, unlike other .slice. I might have missed some, but the first line I mentioned looks like the likely candidate. Edit: or IDK, I do not see how quote can have an undefined text: it's provided by the core, and it should always be a string.

WofWca commented 1 week ago

@Simon-Laux also encountered this issue:

must be in react render function and inside of the message list+composer component, because that error boundary was triggered. I also can not reproduce it with the echo bot. basically I was quickly switching between quote messages while your answers came in.

And I myself also just managed to reproduce this with echo@nine.testrun.org. I sent a message to it and starting quickly pressing Ctrl+Up to quote, and got the crash: Cannot read properties of undefined (reading 'slice').

And indeed it points to this line, Message.tsx:805:28):

https://github.com/deltachat/deltachat-desktop/blob/78fef8b6b45329250c369dc23bd1c4bcd02adca5/packages/frontend/src/components/message/Message.tsx#L805

However, I am not 100% sure that this is the very same issue as in the original post.

WofWca commented 1 week ago

This is what I got by putting a conditional breakpoint quote.text == undefined there.

image

Looks like these two pieces of code could be causing the crash:

https://github.com/deltachat/deltachat-desktop/blob/f9362a941bc6568dce3859052b3744ab925c1a88/packages/frontend/src/components/composer/Composer.tsx#L599-L602

https://github.com/deltachat/deltachat-desktop/blob/f9362a941bc6568dce3859052b3744ab925c1a88/packages/frontend/src/components/composer/Composer.tsx#L662-L665

They actually mutate the state, draftState, bypassing _setDraft, and make the state invalid (because .quote is missing the required properties). draftRef was introduced in 4bbdbe390b03e15eb059ca6af15a44156413ee44.

I think this issue should belong to the "New Composer" project, given that it is not super severe. Un-assign it from the project if you disagree.