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

Video is freezing after few seconds in the new 2.18.2 version #10808

Closed
menscikov opened this issue Nov 23, 2022 · 14 comments
Closed

Video is freezing after few seconds in the new 2.18.2 version #10808

menscikov opened this issue Nov 23, 2022 · 14 comments
Assignees

Comments

@menscikov
Copy link

menscikov commented Nov 23, 2022

ExoPlayer Version

2.18.2

Devices that reproduce the issue

Xiaomi Redmi Note 11 Pro+ 5G

Reproduction steps

  1. You have to set cookie ("Cookie" for HttpDataSource.Factory -> .setDefaultRequestProperties()) for this video to be able to play it in ExoPlayer;
  2. Open video.

Expected result

Video must work without any issues.

Actual result

Video is freezing.
It was working fine in 2.18.1.

Media

Link to the video stream will be sent to email.

@menscikov menscikov changed the title Video is freezing after 1 second Video is freezing after few seconds Nov 23, 2022
@menscikov menscikov changed the title Video is freezing after few seconds Video is freezing after few seconds in the new 2.18.2 version Nov 23, 2022
@christosts christosts self-assigned this Nov 23, 2022
@christosts
Copy link
Contributor

The stream is working fine, I tried two different Pixel devices (4 & 6), and played for ~1 minute on each device. Are you seeing this only on the Xiaomi device? Does it reproduce all the time? If yes, can you also send a bugreport?

Thanks

@menscikov
Copy link
Author

menscikov commented Nov 23, 2022

The stream is working fine, I tried two different Pixel devices (4 & 6), and played for ~1 minute on each device. Are you seeing this only on the Xiaomi device? Does it reproduce all the time? If yes, can you also send a bugreport?

Thanks

Hello, thanks for testing.

I opened this video on Amazon Fire Stick, Android 9. It's working fine.
Xiaomi Redmi Note 11 Pro+ 5G, Android 12 device, video is freezing after 2-3 seconds but sound is playing. After 5 seconds it starts buffering forever.

@menscikov
Copy link
Author

menscikov commented Nov 23, 2022

The stream is working fine, I tried two different Pixel devices (4 & 6), and played for ~1 minute on each device. Are you seeing this only on the Xiaomi device? Does it reproduce all the time? If yes, can you also send a bugreport?

Thanks

Actually you don't need the bugreport from me.

I just tried to open this video in Android Studio on Android Emulator:

  1. Pixel 2 (API 28, Android 9), ABI X86 - video is working fine;
  2. Pixel 2 (API 31, Android 12), ABI X86_64 - video is freezing after 2-3 seconds.
  3. Pixel 6 (API 33, Android 13), ABI X86_64 - video if working fine;

It looks like it's something with Android 12. Maybe with other Android versions also, but i haven't checked them all.

P.S. I re-checked this several times.
P.P.S. I have enabled ffmpeg, av1 & vp9 extensions in my app.

@christosts
Copy link
Contributor

christosts commented Nov 24, 2022

I have not been able to repro this, at least not with the demo app. I used the emulator with Pixel 2 at API 31 with both x64_64 and arm ABIs. The stream has an H264 video track and aac audio, so I don't think the extensions are needed. Can you please attach a bug report after the issue occurs on your side?

@menscikov
Copy link
Author

menscikov commented Nov 24, 2022

I have not been able to repro this, at least not with the demo app. I used the emulator with Pixel 2 at API 31 with both x64_64 and arm ABIs. The stream has an H264 video track and aac audio, so I don't think the extensions are needed. Can you please attach a bug report after the issue occurs on your side?

Hello,

I've sent bugreport few minutes ago.
I've used clean ExoPlayer demo version on my phone.

I've changed initializePlayer() inside PlayerActivity class, because it's trying to use DefaultExtractorsFactory for this video, but it's a HLS video.

HlsExtractorFactory hlsOtherExtractorFactory = new DefaultHlsExtractorFactory(
        DefaultTsPayloadReaderFactory.FLAG_ALLOW_NON_IDR_KEYFRAMES, true);
MediaSource mediaSource = new HlsMediaSource.Factory(DemoUtil.getDataSourceFactory(/* context= */ this))
        .setAllowChunklessPreparation(false)
        .setExtractorFactory(hlsOtherExtractorFactory).createMediaSource(MediaItem.fromUri("link to the video"));
player.setMediaSource(mediaSource);
player.prepare();

@christosts
Copy link
Contributor

thanks for the bug report, will take a look. Meanwhile,

I've changed initializePlayer() inside PlayerActivity class, because it's trying to use DefaultExtractorsFactory for this video, but it's a HLS video.

on the json, just add "extension": "m3u8" to tell the demo app it's an HLS playlist. Or, use mpd for DASH.

@menscikov
Copy link
Author

menscikov commented Nov 24, 2022

thanks for the bug report, will take a look. Meanwhile,

I've changed initializePlayer() inside PlayerActivity class, because it's trying to use DefaultExtractorsFactory for this video, but it's a HLS video.

on the json, just add "extension": "m3u8" to tell the demo app it's an HLS playlist. Or, use mpd for DASH.

I've added extension "extension": "m3u8" and video is working now on Android 12!

But it's not working with this code. Something is broken in the new version here:

HlsExtractorFactory hlsOtherExtractorFactory = new DefaultHlsExtractorFactory(
        DefaultTsPayloadReaderFactory.FLAG_ALLOW_NON_IDR_KEYFRAMES, true);
MediaSource mediaSource = new HlsMediaSource.Factory(dataSourceFactory)
        .setAllowChunklessPreparation(false)
        .setExtractorFactory(hlsOtherExtractorFactory).createMediaSource(MediaItem.fromUri("link to the video"));
player.setMediaSource(mediaSource);
player.prepare();

It looks like that something is broken when i manually select Factory or maybe setting setMediaSource().
I don't use setMediaItems() in my app. I use setMediaSource() and i always select Factory for each video manually.

Despite the fact that the video is working, it plays very slowly, as if the FPS is very low.
In version 2.18.1, the video plays very smoothly.

@menscikov
Copy link
Author

menscikov commented Nov 24, 2022

@christosts,

It's very strange, but if i select dev-v2 branch, then everything is working good. No freezes, no lags, video is playing smoothly.

If i select release-v2 branch, video is freezing.

Maybe something happened after merge?
For example commit 309f24a is working fine, but commit a9444c8 is freezing.

@christosts
Copy link
Contributor

christosts commented Nov 25, 2022

I'm still not able to repro the issue. The stream works fine with Pixel 2 and Pixel 4 emulators at API 31, even when I set the media source as per comment above. Maybe there are still differences in how I run the demo app compared to you. For example I am using the DefaultHttpDataSource and not the CronetDataSource (it appears Cronet doesn't like setting the Cookie header).

Also, I looked at the bug report and I see it was obtained from the Xiaomi device. There are no EventLogger logs which are usually produced by the demo app. There are a few errors that the player cannot understand the input (UnrecognizedInputFormatException) and an HTTP 403 during playback. This is a bit confusing. It looks like the bug report was not obtained with the demo app, so I guess you used your app. But do you expect to see UnrecognizedInputFormatException with your app?

So, let's do two things:

  1. Please share a git patch which has exactly the code changes you do on the demo app to run the stream. This is so I run the demo app with exactly the same changes as you.
  2. Obtain a bug report after the issue occurs on your side and provide it too. I expect to see at least logs with tag EventLogger which are produced by the demo app.

Either send those over email or attach them on this issue. If you attach the git patch here, don't forget to reduct the stream link.

PS The dev-v2 and release-v2 branches contain different commits. Specifically, the dev-v2 branch contains commits that will only be included in 2.19.0. It's good to hear the issue does not occur on dev-v2, but we should figure out if a commit that was cherry picked on the 2.18.2 release is causing any regression.

@menscikov
Copy link
Author

menscikov commented Nov 25, 2022

@christosts i've found the issue.

This commit is fixing the problem: 1eb8a6b

Screenshot 2022-11-25 at 16 53 33

If you replace red code with green one in MediaCodecUtil.java class, video will be lagging.

For some reason in 2.18.2 stable release red code is used. isFormatFunctionallySupported() method is not available in stable release too.

@christosts
Copy link
Contributor

christosts commented Nov 25, 2022

This commit is fixing the problem: 1eb8a6b

Thank you for your investigation. That's interesting, because 1eb8a6b is not included in 2.18.1 which you said works fine. Commit b97a959 is related, so maybe it's this commit that can be causing you issues. The poor performance looks like is caused by choosing a suboptimal decoder.

Can you please still share the git-patch and bug-report I asked above? Even if those CLs are the root causes of the issues, I'd like to see which decoder is picked on your emulator.

@menscikov
Copy link
Author

menscikov commented Nov 25, 2022

I can write here the changes i made in the demo app.
I'm using clean ExoPlayer demo app with only few changes.

  1. AndroidManifest.xml:
    android:usesCleartextTraffic="true"
  2. json file:
      },
      {
        "name": "Video",
        "uri": "Link to the video",
        "extension": "m3u8"
  1. DemoUtil.java
    private static final boolean USE_CRONET_FOR_NETWORKING = false;
    httpDataSourceFactory = new DefaultHttpDataSource.Factory().setAllowCrossProtocolRedirects(true);

I've sent bugreport to the email:

  1. Started demo app on my Xiaomi Redmi Note 11 Pro+ 5G phone;
  2. Opened video;
  3. Watched it for 10 seconds. Video is playing, but is lagging;
  4. Closed demo app;
  5. Wrote in Android Studio Terminal -> adb bugreport

P.S. If i cherry pick that commit into release-v2, video is playing smoothly.

@christosts
Copy link
Contributor

Thanks for the bug-report. Here are two interesting logs

MediaCodecInfo: NoSupport [sizeAndRate.cover, 1920x1080@50.0] [c2.mtk.avc.decoder, video/avc] [pissarropro, 21091116UG, Xiaomi, 31]
...
videoDecoderInitialized [eventTime=5.08, mediaPos=10760.00, window=0, period=0, c2.android.avc.decoder]

The HW decoder on this device (c2.mtk.avc.decoder) reports that it does not support 1920x1080@50.0, hence ExoPlayer picks the software decoder c2.android.avc.decoder. Commit b97a959 changed how we query the decoder for resolution and frame rate support, using the MediaCodecInfo.VideoCapabilities.getSupportedPerformancePoints() API. We don't have a bug-report from the device when using 2.18.1 to compare the logs, but it could be MediaCodecInfo.VideoCapabilities.getSupportedPerformancePoints() on this device is reporting difference capabilities compared to the MediaCodecInfo.VideoCapabilities.areSizeAndRateSupported() which ExoPlayer was calling until 2.18.1.

1eb8a6b is already submitted and the player prefers the HW decoder over the SW one, so I'll ask you to wait until the next release is out.

@menscikov
Copy link
Author

Thank you.

I can make the bugreport from 2.18.1 tomorrow if you need it.
At this moment i will cherry pick that commit into 2.18.2 release until new version is out.

@google google locked and limited conversation to collaborators Jan 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants