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

Performance problem on Firefox if video is placed in a room #3470

Closed
takahirox opened this issue Dec 3, 2020 · 13 comments · Fixed by #5677
Closed

Performance problem on Firefox if video is placed in a room #3470

takahirox opened this issue Dec 3, 2020 · 13 comments · Fixed by #5677
Labels
bug jira-hubs needs triage For bugs that have not yet been assigned a fix priority

Comments

@takahirox
Copy link
Contributor

takahirox commented Dec 3, 2020

Description

FPS number in a room is significantly worse on Firefox if video is placed in a room.

To Reproduce

Access this "room with video"

https://hubs.mozilla.com/rc7gbkQ/crazy-honored-nation

And also access this "room without video"

https://hubs.mozilla.com/PsvaJ6i/clear-authentic-space

And compare the fps number displayed at the bottom right.

In my Desktop Windows with NVIDIA GeForce GTX 1080

Browser With video Without video
Firefox Nightly 30fps 60fps
Chrome 60fps 60fps

Expected behavior
The fps number in a "room with video" on Firefox should be as good as the one on Chrome.

Hardware

  • Device: Desktop
  • OS: Windows
  • Browser: Firefox

Additional context
Add any other context about the problem here.

┆Issue is synchronized with this Jira Task

@takahirox takahirox added bug needs triage For bugs that have not yet been assigned a fix priority labels Dec 3, 2020
@takahirox
Copy link
Contributor Author

Jim's case: Windows, Nvidia RTX 2080

Browser With video Without video
Firefox 90fps 135fps
Chrome 144fps 144fps

Dom's case: Linux, NVidia RTX 2080

Browser With video Without video
Firefox 39-45fps 42-47fps
Chrome 120fps 120fps

(In Dom's case, I guess the performance problem on Firefox seems from generic (JS engine?) issue rather than video stuffs.)

@takahirox
Copy link
Contributor Author

takahirox commented Dec 3, 2020

I took the profile on Firefox.

image

The remarkable thing is .texImage2D() cpu time is huger with video. I guess Firefox has a problem uploading video to GPU?

The result of another Firefox profile which can profile the lower level. It also shows that uploading video seems to waste long time.

image

@takahirox
Copy link
Contributor Author

Reported to bugzilla https://bugzilla.mozilla.org/show_bug.cgi?id=1680851

@netpro2k
Copy link
Contributor

The upstream VideoTexture in Three also makes this gap even worse since they now use requestVideoFrameCallback to reduce the work to only upload when there are actually new video frames, but only Chrome supports this currently https://github.com/mrdoob/three.js/blob/dev/src/textures/VideoTexture.js#L22.

I do think we should re-introduce a FPS cap on video frame uploads.. We had one at some point but it has been removed, and I can't really remember why. Hard limiting to something like 30 FPS should at least help mitigate this problem a bit.

Ultimately this problem eventually goes away with https://www.khronos.org/registry/webgl/extensions/proposals/WEBGL_video_texture/ since this will prevent the need for the GPU -> CPU -> GPU copy of video frames going on now with the current pipeline, but that's probably a long ways off from being usable.

@mattrossman
Copy link
Contributor

360 videos are especially bad, they bring Firefox down to ~5 FPS which makes that feature unusable for me.

@takahirox
Copy link
Contributor Author

From mrdoob/three.js#21746

There might be a chance that video play performance on Firefox can be improved by setting the video texture format RGBA.

@takahirox
Copy link
Contributor Author

Wow, RGBA format works really well on my end. 15 fps became 60fps.

11.2MB mp4 video + desktop Windows.

RGB RGBA
Firefox 15fps 60fps
Chrome 60fps 60fps

@mattrossman
Copy link
Contributor

Holy cow, same result here on the big 360 video I was having trouble with. Went from 5 FPS to just under 60 FPS. Great find @takahirox!

@takahirox
Copy link
Contributor Author

The root issue may have been resolved on Firefox end.

https://bugzilla.mozilla.org/show_bug.cgi?id=1680851

We should test again and remove the workaround if we confirm it's fixed.

@takahirox
Copy link
Contributor Author

I tested on Windows Firefox Nightly. Unfortunately the problem hasn't been resolved yet.

@netpro2k
Copy link
Contributor

We may want to aim to make most things RGBA anyway even if this issue does get fixed in Firefox, as many platforms end up emulating RGB (not specific to videos): https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#some_formats_e.g._rgb_may_be_emulated

@takahirox
Copy link
Contributor Author

takahirox commented Jun 10, 2022

Upstream Three.js seemed to have removed RGBFormat. The workaround can be removed when upgrading our Three.js anyways.

https://github.com/mrdoob/three.js/wiki/Migration-Guide#136--137

@johnshaughnessy
Copy link
Contributor

Will remove the workaround in b89f1e7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug jira-hubs needs triage For bugs that have not yet been assigned a fix priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants