aws / amazon-ivs-react-native-player

A React Native wrapper for the Amazon IVS iOS and Android player SDKs.
Apache License 2.0
299 stars 31 forks source link

[ios]: HLS (m3u8) vs mp4 - very high energy impact + thermal throttling (display brightness dimming) #95

Open hirbod opened 2 years ago

hirbod commented 2 years ago

Hi,

I did some energy impact testing and also noticed that when I am using HLS vs mp4, mp4 consumes way less CPU (which is kinda expected since it does have less Network and parsing overhead), but my iPhone 13 Pro Max heats up pretty heavy, thermal state jumps from nominal to serious and the energy impact is super high.

Test device

mp4

Bildschirmfoto 2022-09-26 um 21 17 05

HLS

Bildschirmfoto 2022-09-26 um 21 00 15

Is there a way to make IVS more battery friendly? My streams just have 2 qualities (480p and 720p).

The screenshot with better energy consumption was achieved with mp4 instead of HLS.

I really couldn't find much information around that.

hirbod commented 2 years ago

It looks like the CPU usage is different when I use a live stream (energy consumption is very high but I never reach the point where my screen brightness dims and I don't feel like the device is heating up).

It's more like it has issues with very simple and default m3u8 files, even though when you only deliver one quality. The live video example URL on the README does not heat up the phone. There is some heavy CPU usage going on - I think related to how the m3u8 is built.

Looks like m3u8 like this one are heavy

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=2800000,RESOLUTION=720x1280
720x1280/video.m3u8

Here is an example that smashes my iPhone: https://d3rlna7iyyu8wu.cloudfront.net/skip_armstrong/skip_armstrong_multi_language_subs.m3u8

This one gets the CPU

Bildschirmfoto 2022-09-27 um 22 08 05 Bildschirmfoto 2022-09-27 um 22 08 16

up to 203%, the others have been ~103%, wile MP4 is 4-15% CPU.

hirbod commented 2 years ago

After comparing this to native AVAsset/AVFoundation and react-native-video vs expo-av, I can tell you that this is only happening with this library. There is an internal issue with the IVS SDK on iOS which causes HLS to go nuts on the CPU. @maxstoller. Android is fine. Turning logLevel to 1 didn't give me any useful insights and since the source for IVS is not open, I could not dig into this any further. I'd really appreciate if this could be investigated.

I played with every prop there is (removing observers, using quality etc). No chance to drop the CPU down to 4-15% - where it belongs.

maxstoller commented 2 years ago

We have seen “Very High” energy usage during normal playback of IVS streams possibly due to the network activity needed for low latency playback.

Are you able to reproduce the high CPU usage issue using any of the example IVS test streams?

hirbod commented 2 years ago

@maxstoller I see better results with the IVS test streams (as also pointed out in my posts already) but I see very bad results with anything thats not IVS. I really don't want to have an App with multiple players included for video coming from IVS and non-ivs. The issue is iOS only and Android works fine with HLS and Mp4. iOS on the other hand works fine only for direct mp4 urls, while it has okish results for IVS streams and terribe results for anything else.

Is it possible to disable the low latency playback to circumvent this? The available flags (I tested really all of them) do not change anything. And what I also figured for non ivs-hls streams in 95% of the times that the audio has a small stutter between 3 and 5 seconds, mostly 5 seconds exactly.

anatoleblanc commented 1 year ago

Any update on that? Temperature of my iphone is rising from 23 to 30 degrees while reading HLS streams.