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

[BUG]: Video's aspect ratio changing on android when restarting with repeat set to true #4187

Open
ElChawich opened this issue Sep 20, 2024 · 16 comments · Fixed by #4205 · May be fixed by #4219
Open

[BUG]: Video's aspect ratio changing on android when restarting with repeat set to true #4187

ElChawich opened this issue Sep 20, 2024 · 16 comments · Fixed by #4205 · May be fixed by #4219
Labels
Accepted Issue is confirmed and accepted by maintainers team bug Missing info Some information from template are missing Missing repro Issue reproduction is missing Newer Version Available Platform: Android Repro Provided

Comments

@ElChawich
Copy link

ElChawich commented Sep 20, 2024

Version

6.6.1

What platforms are you having the problem on?

Android

System Version

Android Version 14 One Ui 6.1

On what device are you experiencing the issue?

Real device

Architecture

Old architecture

What happened?

After updating to version 6.6.1, on android when a video repeats its changing the aspect ratio of the video. What was expected to happen is to repeat without affecting the aspect ratio.

Untitled.mp4

Reproduction Link

repository link

Reproduction

Step to reproduce this bug are:

<Video
ref={videoRef}
source={source}
paused={paused || !isActive || !screenIsFocused}
playWhenInactive={false}
resizeMode={'contain'}
muted={muted}
playInBackground={false}
ignoreSilentSwitch='ignore'
style={dynamicStyles.video}
onProgress={onProgress}
repeat={true}
poster={{
source: { uri: thumbnail },
resizeMode: "contain"
}}
/>

@ElChawich ElChawich added the bug label Sep 20, 2024
Copy link

Thank you for your issue report. Please note that the following information is missing or incomplete:

  • reproduction
  • reproduction link

Please update your issue with this information to help us address it more effectively.

Note: issues without complete information have a lower priority

@github-actions github-actions bot added Platform: Android Missing info Some information from template are missing Missing repro Issue reproduction is missing labels Sep 20, 2024
Copy link

Thank you for your issue report. Please note that the following information is missing or incomplete:

  • reproduction link

Please update your issue with this information to help us address it more effectively.

Note: issues without complete information have a lower priority

Copy link

Thank you for your issue report. Please note that the following information is missing or incomplete:

  • reproduction link

Please update your issue with this information to help us address it more effectively.

Note: issues without complete information have a lower priority

@Pingou
Copy link

Pingou commented Sep 24, 2024

Same issue.

@ElChawich ElChawich changed the title [BUG]: Video's aspect ratio changing on video's repeat on android [BUG]: Video's aspect ratio changing on android when restarting with repeat set to true Sep 25, 2024
Copy link

Thank you for your issue report. Please note that the following information is missing or incomplete:

  • reproduction link

Please update your issue with this information to help us address it more effectively.

Note: issues without complete information have a lower priority

There is a newer version of the library available. You are using version 6.6.1, while the latest stable version is 6.6.2. Please update to the latest version and check if the issue still exists.

Note: If the issue still exists, please update the issue report with the latest information.

@freeboub
Copy link
Collaborator

I don't reproduce the issue with the sample app...
Can you give a reproducible sample please ?
Maybe it comes from a specific video url.

@freeboub
Copy link
Collaborator

Maybe you can try with this patch, I suspect this is the root ause

diff --git a/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java
index 45624d6f..e8dc92c9 100644
--- a/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java
+++ b/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java
@@ -275,6 +275,7 @@ public final class ExoPlayerView extends FrameLayout implements AdViewProvider {
                     case 90:
                     case 270:
                         layout.setVideoAspectRatio(format.width == 0 ? 1 : (format.height * format.pixelWidthHeightRatio) / format.width);
+                        break;
                     default:
                         layout.setVideoAspectRatio(format.height == 0 ? 1 : (format.width * format.pixelWidthHeightRatio) / format.height);
                 }

@freeboub freeboub added the Accepted Issue is confirmed and accepted by maintainers team label Sep 28, 2024
@freeboub
Copy link
Collaborator

I confirm this is the good fix, I will open a PR with this patch

@Pingou
Copy link

Pingou commented Sep 28, 2024

@freeboub merci !

@ElChawich
Copy link
Author

@freeboub the issue still persists in v6.6.4

@freeboub
Copy link
Collaborator

freeboub commented Oct 4, 2024

@freeboub the issue still persists in v6.6.4

Please provide a sample to reproduce the issue .

@ElChawich
Copy link
Author

ElChawich commented Oct 4, 2024

@freeboub the issue still persists in v6.6.4

Please provide a sample to reproduce the issue .

`const isActive = activePage === indexInFeed;
const [videoOrientation, setVideoOrientation] = useState(VIDEO_ORIENTATION.PORTRAIT);

const getResizeMode = useMemo(() => {
if (videoOrientation === VIDEO_ORIENTATION.LANDSCAPE) return 'contain';
if (windowHeight <= MIN_SCREEN_HEIGHT) return 'cover';
return 'contain';
}, [videoOrientation]);

const isPaused = useMemo(() => {
return paused || !isActive || !screenIsFocused;
}, [paused, isActive, screenIsFocused]);

if (Math.abs(activePage - indexInFeed) > 2 || !source) return null;

return (

<Video
ref={videoRef}
onLoad={({ naturalSize }) => {
if (naturalSize && naturalSize.orientation) setVideoOrientation(naturalSize.orientation);
}}
source={source}
paused={isPaused}
poster={{
source: { uri: thumbnail },
resizeMode: getResizeMode
}}
playWhenInactive={false}
resizeMode={getResizeMode}
style={styles.video}
muted={muted}
playInBackground={false}
ignoreSilentSwitch='ignore'
onProgress={onProgress}
repeat={true}
bufferingStrategy='DependingOnMemory'
bufferConfig={{
minBufferMs: 1000,
maxBufferMs: 10000,
bufferForPlaybackAfterRebufferMs: 1000,
bufferForPlaybackMs: 1000
}}
onError={error => {
console.log(error);
}}
/>
`

@ElChawich
Copy link
Author

@freeboub commenting out lines 277 and 280 in ExpoPlayerView.java file fixed the issue. Not sure why this code is being triggered in the first place even though the rotation hasn't changed

@freeboub
Copy link
Collaborator

freeboub commented Oct 4, 2024

Please provide it in a git repository with sample video. It is painful to try to replicate issues...
Or easier for you, just try with the basic sample from the repository with your stream

@ElChawich
Copy link
Author

@freeboub here is a repository link where you can reproduce. Please test it on android, the issue happens after the video repeats once or twice

@freeboub freeboub reopened this Oct 4, 2024
@freeboub
Copy link
Collaborator

freeboub commented Oct 5, 2024

As you see I have reopen the ticket, with this video it is also reproduced with the sample app (Thank you for sharing it !).
I try to fix the issue but I fail in a painfull cycle of regression.
BTW, I think we are in an issue related to this is an exoplayer issue: androidx/media#1207
It would be interesting handle the issue on Exoplayer side, but I don't think I will have time to handle it ...

But ! There is an issue in your manifest file, if you open the m3u you will see following configuration :

#EXT-X-STREAM-INF:BANDWIDTH=5000000,AVERAGE-BANDWIDTH=4000000,CODECS="mp4a.40.2,avc1.640028",RESOLUTION=1920x1080,CLOSED-CAPTIONS=NONE

which means you stream is 1920X1080 where it is 1080X1920

You can compare with this stream which is landscape: https://bitmovin-a.akamaihd.net/content/sintel/hls/playlist.m3u8

As a conclusion:

  • There is an issue with exoplayer which don't report consistant data
  • There is an issue on RNV which doesn't handle consistently aspect ratio. (I will provide a fix for that)
  • There is an issue with your stream.

#nightmare 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue is confirmed and accepted by maintainers team bug Missing info Some information from template are missing Missing repro Issue reproduction is missing Newer Version Available Platform: Android Repro Provided
Projects
None yet
3 participants