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 #5451 : java.lang.IllegalStateException - Media player has not been previously initialized #5475

Merged

Conversation

subhajitxyz
Copy link
Collaborator

@subhajitxyz subhajitxyz commented Aug 1, 2024

Explanation

Fixes #5451

The error occurs if the release is attempted before the MediaPlayer is initialized or if releaseMediaPlayer() is called multiple times. To address this, I have modified releaseMediaPlayer() to only release the MediaPlayer if it has not already been released. These changes properly handle the situation when releaseMediaPlayer() is called before initialization.

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

For UI-specific PRs only

If your PR includes UI-related changes, then:

  • Add screenshots for portrait/landscape for both a tablet & phone of the before & after UI changes
  • For the screenshots above, include both English and pseudo-localized (RTL) screenshots (see RTL guide)
  • Add a video showing the full UX flow with a screen reader enabled (see accessibility guide)
  • For PRs introducing new UI elements or color changes, both light and dark mode screenshots must be included
  • Add a screenshot demonstrating that you ran affected Espresso tests locally & that they're passing

@subhajitxyz subhajitxyz requested a review from a team as a code owner August 1, 2024 12:37
@adhiamboperes
Copy link
Collaborator

Hi @subhajitxyz, could you please ensure that you have added tests for the changes? We want to make sure the issue does not recurr. @theMr17, @Vishwajith-Shettigar, could you please keep an eye out incase @subhajitxyz has questions about testing?

@theMr17
Copy link
Collaborator

theMr17 commented Aug 3, 2024

Hi @subhajitxyz, could you please ensure that you have added tests for the changes? We want to make sure the issue does not recurr. @theMr17, @Vishwajith-Shettigar, could you please keep an eye out incase @subhajitxyz has questions about testing?

Sure, @subhajitxyz please reach out if you have any trouble or doubts while writing tests!

@subhajitxyz
Copy link
Collaborator Author

@theMr17 Actually i didn't clearly understand the question of adhiamboperes.

@subhajitxyz
Copy link
Collaborator Author

If mediaplayer is not initialized and releaseMediaPlayer() is called, for this test was added already.
If releaseMediaPlayer() is called multiple times, should i add test for it? @theMr17

@theMr17
Copy link
Collaborator

theMr17 commented Aug 3, 2024

If mediaplayer is not initialized and releaseMediaPlayer() is called, for this test was added already. If releaseMediaPlayer() is called multiple times, should i add test for it? @theMr17

Yes, you are right! For every change we make, we should add tests to verify that the behavior is handled correctly. Please add a test for the case you mentioned. This will help us verify that the if (!isReleased) check is working correctly.

@subhajitxyz
Copy link
Collaborator Author

Ok , soon I will add required tests.

@subhajitxyz
Copy link
Collaborator Author

Hi @adhiamboperes, I have added a test for the changes. The test assures that consecutive calls of releaseMediaPlayer() do not throw exceptions.

@theMr17
Copy link
Collaborator

theMr17 commented Aug 3, 2024

testController_consecutively_releasePlayer_callShouldNot_fail() or testController_consecutively_releasePlayer_callShouldNot_throwException(). which name of the test function is good? @theMr17

Please take a look at the test naming convention described here: https://github.com/oppia/oppia-android/wiki/Oppia-Android-Testing#naming-convention. Go ahead with a name which you think should be right per this convention. The name could be verified while reviewing the PR.

Copy link
Collaborator

@adhiamboperes adhiamboperes left a comment

Choose a reason for hiding this comment

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

Thanks @subhajitxyz! Please take a look at the comments. Do you also have explicit reprduction steps for this bug? It would be great if you could add those to the issue body for future reference.

@adhiamboperes
Copy link
Collaborator

@subhajitxyz, once your PR is ready for review, assign back to the reviewer.

@subhajitxyz subhajitxyz removed their assignment Aug 7, 2024
@theMr17
Copy link
Collaborator

theMr17 commented Aug 7, 2024

Hi @subhajitxyz, here is a guide to assign PRs to reviewers: https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section

@subhajitxyz
Copy link
Collaborator Author

@subhajitxyz
Copy link
Collaborator Author

@adhiamboperes, PTAL.

@Vishwajith-Shettigar
Copy link
Collaborator

Hi @subhajitxyz, update your branch with base branch, before assigning back to reviewer and make sure all checks pass.

Copy link
Collaborator

@adhiamboperes adhiamboperes left a comment

Choose a reason for hiding this comment

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

Thanks @subhajitxyz! This LGTM!

Could you please fill this form in once this PR has been merged?

Copy link

oppiabot bot commented Aug 8, 2024

Assigning @BenHenning for code owner reviews. Thanks!

@subhajitxyz
Copy link
Collaborator Author

Thanks @adhiamboperes , I will fiil the form.

@adhiamboperes adhiamboperes merged commit bfa471e into oppia:develop Aug 8, 2024
38 checks passed
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.

[BUG]: java.lang.IllegalStateException - Media player has not been previously initialized
5 participants