googlevr / gvr-unity-sdk

Google VR SDK for Unity
http://developers.google.com/vr/unity/
Other
2.71k stars 1.1k forks source link

Video framerate drop #869

Open rocqetQueen opened 6 years ago

rocqetQueen commented 6 years ago

Summary: We are developing a video player for daydream using the GoogleVR SDK and Unity 5.6.5f1. Right now we are using v1.40.0 and we wanted to upgrade to 1.100.1 or 1.120.0. To see if it was worth the effort of upgrading the projects, we've created three basic projects for each version of the SDK we wanted to compare so we wouldn't have any of our components messing up with the results.

To our surprise, the results were really bad with the new versions, in some phones we are loosing near 20 fps in the video playback.

All three projects have the same settings and their scene is the same, the only thing different is the SDK version. The scene we have built consists on a camera and a sphere with the GVRVideoplayerTexture and AutoPlayVideo scripts, nothing else.

We've tried to play the same video with the three versions, which is 60 fps, and we are getting a really good framerate with version 1.40.0 but a considerable drop using 1.100.1 and 1.120.0. These are the results:

v1.40.0
Samsung S8 (Android 8.0, Exynos): 56 fps Samsung S9 (Android 8.0, Exynos): 58 fps Google Pixel XL (Android 8.1.0): 58-59 fps ZTE Axon 7 (Android 7.1.1): 53-54 fps

v1.100.1
Samsung S8 (Android 8.0, Exynos): 40 fps Samsung S9 (Android 8.0, Exynos): 43 fps Google Pixel XL (Android 8.1.0): 41 fps ZTE Axon 7 (Android 7.1.1): 39-40 fps

v1.120.0
Samsung S8 (Android 8.0, Exynos): 40 fps Samsung S9 (Android 8.0, Exynos): 42 fps Google Pixel XL (Android 8.1.0): 41 fps ZTE Axon 7 (Android 7.1.1): 39-40 fps

Found using:

Adam-VisualVocal commented 6 years ago

Have you tried messing with Application.targetFrameRate and possibly also QualitySettings.vSyncCount? We found, at least on iPhone, that the newer versions of Unity and/or GVR SDK were setting the target frame rate to 30. I'm not sure about Android though.

rocqetQueen commented 6 years ago

@Adam-VisualVocal thank you for your suggestion but that doesn't seem to be the problem. The application framerate is not blocked to any value, it can go to 60 fps easily, the problem is the video framerate

rusmaxham commented 6 years ago

What are you using to play video in VR?

rocqetQueen commented 6 years ago

@rusmaxham what do you mean?

rusmaxham commented 6 years ago

What Unity component are you configuring to play your video? Is it Unity's built-in Video Player component, GvrVideoPlayerTexture, or some third party video player from the Asset Store?

rocqetQueen commented 6 years ago

We are using GvrVideoPlayerTexture

rusmaxham commented 6 years ago

Could you send me a before and after apk that we can profile?

rocqetQueen commented 6 years ago

@rusmaxham here you have! This APKs stream a 3840x2160 px 60 fps video. I've also added APKs for the 120 and 130 versions as we're facing the issue there also. Let me know if you need the Unity projects too. Thanks!

rocqetQueen commented 5 years ago

@rusmaxham Is there any update on this?

rusmaxham commented 5 years ago

I took a look at your apps, and the main thing that jumps out at me is the use of the h.265 video codec which is known to have poor performance on Pixel devices and a variety of other Android devices. I would advise you encode your video in h.264 instead. I'm not sure why the performance was better with 1.40 of the GVR SDK. We made changes in 1.70 that eliminated an extra video frame copy from the rendering pipeline that resulted in performance gains with all of the (h.264) content we tested with. Obviously, something is poorly interacting with your video with this new code path. My experience with h.265 on Android makes me think you would get better framerate with h.264 video.