[go: nahoru, domu]

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

The progress of the still video screen seems to change in milliseconds #1466

Closed
1 task
kwonjae-lee opened this issue Jun 17, 2024 · 5 comments
Closed
1 task
Assignees
Labels

Comments

@kwonjae-lee
Copy link

Version

Media3 main branch

More version details

No response

Devices that reproduce the issue

Samsung S21+, AOS 13

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

  1. disable release/initialize player on stop/start the activity (from sample)
스크린샷 2024-06-17 오후 11 00 11 2. select 'Clear DASH' -> 'HD (MP4, H264)' (or other MP4 example) 3. click the pause button 4. go background and back to foreground 5. repeat step4 and check the video

Expected result

The progress of the still screen should remain unchanged.

Actual result

The progress of the still screen appears to change in milliseconds.

Media

Screen_Recording_20240617_231732_One.UI.Home.mp4

Bug Report

@kwonjae-lee
Copy link
Author

I found this issue when I tried to re-use a view in RecyclerView.
And it looks similar to this issue - #1278

@tonihei
Copy link
Collaborator
tonihei commented Jun 17, 2024

disable release/initialize player on stop/start the activity (from sample)

First of all, this particular step is not something you should do in a real app because keeping the player (and the codec in particular) while the app is in background may cause unexpected side effects. I understand that you originally reproduced this in RecyclerView, so I appreciate this is just a test setup.

progress of the still screen appears to change in milliseconds

I was not able to reproduce this on my device by using the pause button in the UI, but I think I can reproduce it by calling player.pause() from within Activity.onStop().

The problem may be caused by two different effects:

  1. The video surface is disconnected and reconnected. When the new surface is connected, it cannot receive any previously decoded frames and will instead receive the next available frame.
  2. Depending on the timing of the pause operation, you may also see one or two scheduled frame releases that can't be cancelled even during a pause operation. So when you come back, the preview (a kind of screenshot taken by the system when you left) may be slightly different from the one when coming back to it.

@tonihei tonihei self-assigned this Jun 17, 2024
@kwonjae-lee
Copy link
Author
kwonjae-lee commented Jun 18, 2024

Thanks for your explanation.
And I totally understand your concern( keeping the player (and the codec in particular) while the app is in background may cause unexpected side effects)
I think, this is not a practical problem, as users typically do not perform the same action repeatedly.

But my service has a requirement which is focused on visibility not on performance.
Because there is flicker of screen when I release and initialize the player.
(The screen is black while the player load media file.)
So isn't this supposed to be fixed? I mean, should I explain to my team member that this is not a problem.

@tonihei
Copy link
Collaborator
tonihei commented Jun 18, 2024

So isn't this supposed to be fixed?

Could you highlight what exactly you are trying to achieve? There may be alternatives to your current usage pattern.

But generally, the way codecs work is that they release frames to a surface and there is no way to get the last released frame back again. To avoid this, you need to either recreate the codec or not destroy the surface:

  • New codec, new (or same) surface -> some initial delay during set up, but can start with the previous frame precisely. This is what the Media3 demo is doing by default.
  • Same codec, new surface -> current test setup as described above, can only release the next frame
  • Same codec, same surface -> keeps content, but there is no guarantee you can keep the surface. Surfaces are automatically destroyed when the Activity is stopped or they are no longer connected to the view hierarchy. If you handle them in RecyclerView, you may be able to move an existing Surface to an out-of-screen position while you don't need it, or you try SurfaceControl to reparent an exiting Surface in another View.

The screen is black while the player load media file

The typical solution to this is to show a placeholder image. You may be able to achieve this by using TextureView and then call getBitmap when the surface is destroyed. Or preferably, you can start preparing the output early enough so that it's already ready when it comes into view.

@kwonjae-lee
Copy link
Author

Thank you, you already suggested alternative solution for me.
Actually I wanted to keep the surface even if it was disconnected from the view hierarchy.
I used "TextureView" and the "TextureView" was destroyed when detached from window (as you mentioned)
I think "SurfaceControl" or "Placeholder image"(from "getBitmap") can be a solution.

@androidx androidx locked and limited conversation to collaborators Aug 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants