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

Check scope active for awaiting player #578

Merged
merged 5 commits into from
Jan 23, 2025

Conversation

brocollie08
Copy link
Contributor

@brocollie08 brocollie08 commented Jan 22, 2025

Change Type (required)

Indicate the type of change your pull request is:

  • patch
  • minor
  • major
  • N/A

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs
📦 Published PR as canary version: 0.10.2--canary.578.19394

Try this version out locally by upgrading relevant packages to 0.10.2--canary.578.19394

@brocollie08 brocollie08 added the patch Increment the patch version when merged label Jan 22, 2025
Signed-off-by: brocollie08 <[email protected]>
@brocollie08
Copy link
Contributor Author

/canary

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.76%. Comparing base (2766c6b) to head (61080b0).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #578   +/-   ##
=======================================
  Coverage   89.76%   89.76%           
=======================================
  Files         331      331           
  Lines       19840    19840           
  Branches     1949     1949           
=======================================
  Hits        17809    17809           
  Misses       2017     2017           
  Partials       14       14           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brocollie08 brocollie08 marked this pull request as ready for review January 22, 2025 23:04
@@ -78,7 +80,7 @@ public open class PlayerViewModel(flows: AsyncFlowIterator) : ViewModel(), Andro
deferredPlayer.getCompleted()
} else {
runBlocking {
deferredPlayer.await()
if (viewModelScope.isActive) deferredPlayer.await() else throw IllegalAccessError("Accessing Player instance when ViewModelScope is no longer active")
Copy link
Member

Choose a reason for hiding this comment

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

  1. Can we do the check outside the runBlocking to avoid the perf overhead of creating coroutines and blocking the thread on that coroutine context?

  2. If the scope that deferredPlayer executes in changes, this check would need to be updated to. It'd probably be better to do deferredPlayer.isActive if that's possible to check "activeness" explicitly against the Deferred we're trying to access.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to release so no longer needed to check and return or throw here

Comment on lines 165 to 169
try {
release()
} catch (e: IllegalAccessError) {
Log.e("AndroidPlayer", e.message ?: "IllegalAccessError in AndroidPlayer")
}
Copy link
Member

Choose a reason for hiding this comment

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

Do you think this might swallow real IllegalAccessErrors? Can/should we be more targeted with what we're wrapping in try/catch, or maybe even not throw anything at all? i.e.:

    public fun release() {
        if (deferredPlayer.isCompleted) {
            player.release()
        }
    }

@brocollie08 brocollie08 merged commit a8f8dd4 into main Jan 23, 2025
11 checks passed
@brocollie08 brocollie08 deleted the android-player-early-access-error branch January 23, 2025 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants