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

Bug: App crashes unpredictably. #2342

Closed
Azad99-9 opened this issue Jan 21, 2024 · 11 comments
Closed

Bug: App crashes unpredictably. #2342

Azad99-9 opened this issue Jan 21, 2024 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@Azad99-9
Copy link
Contributor

Azad99-9 commented Jan 21, 2024

Describe the bug

  1. The signup process occasionally results in the app crashing. Specifically, the signup flow functions correctly at times but experiences issues and crashes unpredictably at other times.
  2. After login switching organisations repeatedly is resulting in app crash.

To Reproduce
Steps to reproduce the behavior:

There isn't any defined way to reproduce this behaviour.

  1. Launch Talawa app
  2. Play around Login,signup & organisation switching functionalities.
  3. Try different combinations of above functioinalities
    example combination:
    a. login to the app.
    b. switch organisation.
    c. logout.
    d. Again signup and so on...
  4. At some point the app crashes.

Expected behavior
App shouldnot crash and work predictably.

Actual behavior
some instances of the issue:

**When switching organisations after Login.**
app_crash_switching_org.mp4
**When signup**
app_crash_signup.mp4

Screenshots
Logs when issue is encountered.
Screenshot from 2024-01-22 02-50-08

Screenshot_20240131-225639

Additional details

  • See above.

Potential internship candidates
Please read this if you are planning to apply for a Palisadoes Foundation internship #359

@Azad99-9 Azad99-9 added the bug Something isn't working label Jan 21, 2024
@github-actions github-actions bot added the unapproved Unapproved, needs to be triaged label Jan 21, 2024
@Dante291
Copy link
Contributor

Dante291 commented Jan 22, 2024

@Azad99-9 does it always crashes when switching to another org? also is it happening after the latest upstream fetch?

@Azad99-9
Copy link
Contributor Author

@Dante291 the trigger why the app crashes is uncertain, sometimes it crashes if we signup other times it crashes if we switch orgs.
I was facing this prior to latest fetch too but the frequency was less. Post the latest fetch the frequency increased so I thought it should be addressed.

@Azad99-9
Copy link
Contributor Author

Azad99-9 commented Jan 22, 2024

@Cioppolo14 @noman2002 I would like to work on this, please assign me.

@Cioppolo14 Cioppolo14 removed the unapproved Unapproved, needs to be triaged label Jan 22, 2024
@Azad99-9
Copy link
Contributor Author

Azad99-9 commented Jan 24, 2024

@palisadoes @literalEval @noman2002 @Ayush0Chaudhary I have found the root cause of this issue, need your assistance.

cause of app crash: Race condition of refreshToken method.

The below situation is causing the race-condition.

  1. Upon app startup or user actions like logging in or signing up, the initialization methods of multiple screens, including OrganisationFeed, ExploreEvents, and ProfileScreen, are invoked concurrently.
  2. Within the initialization method of each mentioned screen, corresponding functions like getPosts and getEvents are called.
  3. The issue arises because these functions include a call to the refreshToken method in their implementation.
    Screenshot from 2024-01-25 03-05-44
    Screenshot from 2024-01-25 03-05-17

This poses a concern as the token is being refreshed before each API call for fetching posts and events, which may not be an optimal approach for session handling. Additionally, when these functions are called concurrently, it introduces a race condition in the refreshToken method, as observed in this scenario. Hence causing the app to crash.

fixes:

  1. To fix this issue specifically for this bug we could simply handle the above race condition by some flag and fix it.

  2. But I feel it would be more beneficial if we have a long term fix for this,
    like if we can introduce a centralized session management mechanism into the application which strategically refreshes the token at regular intervals of time. This way not only at this instance but also in future we dont need to worry about these type of race conditions.

I would like to know your thoughts on this, please guide me which approach should i follow ?

@Azad99-9
Copy link
Contributor Author

@palisadoes @noman2002 @literalEval @Ayush0Chaudhary
Respected mentors I understand that you are busy, I request you to please take a moment and kindly look at above comment and guide me which approach to follow. Thanks.

@palisadoes
Copy link
Contributor

We always prefer implementing solutions that will make the code more stable, manageable and readable in the long term

@Azad99-9
Copy link
Contributor Author

@palisadoes Thanks then I will proceed with the long term solution that I have proposed.👍

@Azad99-9
Copy link
Contributor Author

@Cioppolo14 to address the current issue, I need to implement a solution that tackles a broader problem, extending beyond the scope of this issue. I plan to open a new issue for this purpose. Since I already have two assigned issues, could you please advise on whether I can be assigned to the new issue, or should I close this one and open the new issue separately?

@Cioppolo14
Copy link
Contributor

@Azad99-9 I think the best thing would be to close this issue, and make a new one that describes the broader problem, mentioning that it will also resolve the app crashing unpredictably in the process. This way it continues to be mentioned in an active issue, but the new issue will have better details to your new approach. Please tag me when you make it.

@Azad99-9
Copy link
Contributor Author

@Cioppolo14 Thanks doing it.

@Azad99-9
Copy link
Contributor Author

Closing to open a new issue (#2356) which solves this along the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants