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

Add an ExoPlayer settings page #8875

Merged
merged 5 commits into from
Apr 10, 2023
Merged

Conversation

AudricV
Copy link
Member

@AudricV AudricV commented Aug 24, 2022

What is it?

  • Feature (user facing)

Description of the changes in your PR

This PR adds an ExoPlayer settings page to NewPipe's settings, at the current place of the playback load interval size setting (Video and audio settings page).

This page contains three settings:

  • the playback load interval size one, for which its description has been updated to reflect its effect on progressive sources only (its translations have been removed);
  • a new setting to enable ExoPlayer's decoder fallback feature, which could help for issues such as ExoPlaybackException - MediaCodecVideoDecoderException #8016;
  • the media tunneling setting, which is now controllable by the user and not only for debug builds. Media tunneling may be not supported by more devices than the ones on which we disabled this feature before, so I think it is a good idea to allow users to not wait for us to disable this setting on their device on a future release, and also for future code complexity purposes. Users of devices on which media tunneling has been disabled will have to enable manually this setting again on their devices with this change.

More settings could be added in the future, such as ones to change buffer settings.

These settings require a player restart to take effect (this information has been written on the link of this page, in Video and audio settings).

Before/After Screenshots/Screen Record

  • Before:

Video and audio settings before

  • After:
Video and audio settings after ExoPlayer settings

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.

Due diligence

@AudricV AudricV added feature request Issue is related to a feature in the app player Issues related to any player (main, popup and background) labels Aug 24, 2022
@sonarcloud
Copy link

sonarcloud bot commented Aug 24, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@TacoTheDank
Copy link
Member

I'd recommend that, when using multiple sentences for a preference summary, that each sentence end with a period.

E.g. "These changes require a player restart to take effect." Same with the ExoPlayer settings.

@AudricV
Copy link
Member Author

AudricV commented Aug 25, 2022

I'd recommend that, when using multiple sentences for a preference summary, that each sentence end with a period.

This behavior is used in the majority of settings description with multiple settings, so I try to kept the same style.

@TacoTheDank
Copy link
Member

This behavior is used in the majority of settings description with multiple settings, so I try to kept the same style.

I just checked all the settings, and that does seem to be the case. That's kinda weird IMO, but alright. 👍

@sonarcloud
Copy link

sonarcloud bot commented Nov 9, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@glbyers
Copy link

glbyers commented Nov 20, 2022

I agree that having the ability to disable tunneling from settings in the release build is a good thing, but I also believe a tunneling blacklist should be maintained for those devices that don't support it properly. Otherwise you're just going to end up with frustrated users searching forums and whatnot trying to find out why the app is unusable or constantly crashing for them. Even though that switch was available in the debug build, it wasn't once mentioned on the bug report I was following, and not once did I consider it a potential fix. I had to actually go through the whole debugging process to find it. Maybe a knowledgeable dev would have found that much sooner, but I'm just a lowly sys admin; it took some time.

Anyway, give users of the application a nice experience from the get go, without the need for having to hunt down why it won't work for them in the first place.

For those with issues that do manage to find the switch, perhaps also adding the internal device name & API version to the about page would help aid in maintaining the blacklist in future? Rather than someone reporting that "disabling tunneling works for me on a Zephir TS43UHD-2", they could instead report that it works for them on a cvt_mt5886_eu_1g with API version 24 for example.

Anyway, just my 2c.

@opusforlife2
Copy link
Collaborator

but I also believe a tunneling blacklist should be maintained for those devices that don't support it properly

@glbyers The thing is, media tunneling was created for Android TVs in the first place. So bypassing it on TVs makes no sense at all. o_O

Anyway, give users of the application a nice experience from the get go, without the need for having to hunt down why it won't work for them in the first place.

That's the idea. Since all these TVs were working fine before 0.24.0, this is a regression, and a fix for this should fix full screen on all TVs, not specific models. You finding out that media tunneling causes this has been a huge help, so thank you for debugging. ^_^

@glbyers
Copy link

glbyers commented Nov 20, 2022

@glbyers The thing is, media tunneling was created for Android TVs in the first place. So bypassing it on TVs makes no sense at all. o_O

There are a significant number of issues both open and closed in the exoplayer github related to media tunneling. I've seen some of the devs suggest that it's a risky thing to enable by default as it has a high number of device specific problems. I get how valuable it is, and sweet if it works, especially at 4k resolutions. But it's kinda reliant on every device manufacturer that claims to support it to implement it properly. Even with my TV, it's not that the codecs don't support media tunneling, it's more that the audio codec doesn't support changing of the surface after it has been started with tunneling enabled.

I'm not at all arguing against a more general fix. I'm not sure an obscure option is necessarily a general fix though, especially if it defaults to on. It should still default to off for devices it's known not to work with in my mind. Perhaps it needs some clarity so it's obvious what it does, not what it's called. "Hardware decoding" is instantly more recognisable than '"media tunneling" IMO.

FWIW, as I said in the issue. It wasn't working properly prior to 0.24 either. At least for my TV. It's just that having to relaunch it between every video was still a usable solution.

Anyway, you know what they say. Opinions are like something or other. Everyone has one.

@opusforlife2
Copy link
Collaborator

I'm not sure an obscure option is necessarily a general fix though

@glbyers Oh, this PR is not the intended fix. It just happens to contain the workaround you found already. We've asked users in that thread to test it so that we can be sure that everyone's problem was the same and is indeed solved this way.

Don't worry. We'll try to look for a proper fix that doesn't need users to mess around with decoding settings.

@bazipn
Copy link

bazipn commented Dec 4, 2022

Hey this fixes the issue for me on android tv, it is slow as though (probably due to not debugging apk), can this be merged as a quick fix for TV users. Its hard to debug issues on TV compared to phone and I dont think the issue has to do with media tunneling but rather refactoring the player. Thanks.

&& Build.DEVICE.equals("RealtekATV");
// Philips QM16XE
private static final boolean QM16XE_U = Build.VERSION.SDK_INT == 23
&& Build.DEVICE.equals("QM16XE_U");
Copy link
Member

Choose a reason for hiding this comment

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

Mmmh, why are you removing this list completely? We know all these TVs don't work, so by default on such devices tunneling should be disabled. Then the user can go into settings and enable it, but at least it should be off by default.

Copy link
Member

@TobiGr TobiGr May 23, 2023

Choose a reason for hiding this comment

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

Someone needs to write a methid that sets a default value depeding on the device. Otherwise, NewPipe is going to stop working for some users and they certainly not search for a solution in the settings.

// enable media tunneling
if (DEBUG && PreferenceManager.getDefaultSharedPreferences(context)
// Disable media tunneling if requested by the user from ExoPlayer settings
if (!PreferenceManager.getDefaultSharedPreferences(context)
.getBoolean(context.getString(R.string.disable_media_tunneling_key), false)) {
Copy link
Member

Choose a reason for hiding this comment

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

So I would make sure the preference does not get auto-created, and then use !DeviceUtils.shouldSupportMediaTunneling() instead of false as the value to use when the preference is not set.

Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Maybe use_inexact_seek_key should also go into the exoplayer settings?

Do we also want to add an option to enable the setSurface workaround manually?

@opusforlife2
Copy link
Collaborator

Maybe use_inexact_seek_key should also go into the exoplayer settings?

Why? That's a standard player setting, not specific to Exoplayer-related concerns.

@Stypox
Copy link
Member

Stypox commented Mar 3, 2023

Well, it's a setting that changes how exoplayer seeks, so it's more a tecnichal setting. But yeah, it's arguable whether that setting should be under the exoplayer menu or not.

@opusforlife2
Copy link
Collaborator

My understanding of this PR was that it would contain esoteric settings that most users shouldn't be touching. Seek interval is a regular customisable setting.

@AudricV
Copy link
Member Author

AudricV commented Mar 3, 2023

Do we also want to add an option to enable the setSurface workaround manually?

Done.

@sonarcloud
Copy link

sonarcloud bot commented Mar 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

…tting into it

This fragment has been added into SettingsResourceRegistry, to allow searches
in its options.

It has been placed at the place of the previous playback load interval size
setting (so in Video and Audio settings).
This option could help to avoid decoder initialization issues, which falls back
to lower-priority decoders if decoder initialization fails. This may result in
poor playback performance than when using primary decoders.

It is disabled by default, but can be enabled in ExoPlayer settings.
…ing available on release builds

Media tunneling may be not supported by more devices than the ones we
whitelisted before.

As a matter of fact, the list of devices on which media tunneling is disabled
could be not maintainable in the future, especially if the list of devices
grows more and more.

A preferable solution is to allow users to configure this setting themselves,
allowing them to not wait for their device(s) to be whitelisted in a future
NewPipe update.

This solution has been applied in this commit and works on every build type.

The corresponding preference in the debug settings has been of course removed
and the code used to prevent media tunneling activation on specific devices has
been removed.
- Remove redundant player restart requirement note, as it is written on the
ExoPlayer settings description page;
- Add precision about the setting effect/limitation, as it only applies on
progressive contents/media sources and not on every content/media source;
- Remove translations of this description, to ensure that they will be updated
by translators.
…derer setOutputSurface workaround

As some devices not present in ExoPlayer's list may not implement
MediaCodec.setOutputSurface(Surface) properly, this workaround could be useful
on these devices.

It forces ExoPlayer to fall back on releasing and re-instantiating video codec
instances, which is always used on Android 5 and lower due to addition of this
method in Android 6.

To do so, a CustomMediaCodecVideoRenderer, based on ExoPlayer's
MediaVideoCodecRenderer which always return true for the
codecNeedsSetOutputSurfaceWorkaround method has been added, which is used in
CustomRenderersFactory, a class based on DefaultRenderersFactory which always
returns our CustomMediaCodecVideoRenderer as the video renderers.

CustomRenderersFactory replaces DefaultRenderersFactory in the player, in the
case this setting is enabled.
@Stypox Stypox merged commit 6243f34 into TeamNewPipe:dev Apr 10, 2023
@sonarcloud
Copy link

sonarcloud bot commented Apr 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issue is related to a feature in the app player Issues related to any player (main, popup and background)
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants