pupnp / pupnp

libupnp: Build UPnP-compliant control points, devices, and bridges on several operating systems.
https://pupnp.github.io/pupnp
BSD 3-Clause "New" or "Revised" License
353 stars 117 forks source link

Huge battery consumption on iOS since 1.14.0 (SO_REUSEADDR) #328

Open AmarOk1412 opened 3 years ago

AmarOk1412 commented 3 years ago

Hi.

Since pupnp 1.14.0, default configuration is causing a huge CPU consumption located in runMiniServer. This is probably caused by https://github.com/pupnp/pupnp/commit/a3912b04653cdefd6f7b627d73eef6f234a9882c cause SO_REUSEADDR is weirdly handled by iphone devices.

Adding the --disable-reuseaddr option solves this issue. IMHO, SO_REUSEADDR should not be enabled by default on Apple devices

mrjimenez commented 3 years ago

Hi Sébastien,

The default behavior is set in configure.ac or CMakeLists.txt, but this is not currently a platform based choice.

Do you think that this a regression introduced by this commit? Are you able to compile and test with the commit immediately before (https://github.com/pupnp/pupnp/commit/cfbb7910445df185ca34601eabb039c12ec5474c)?

Would it be possible to test this behavior in a PC? Do you have a small test code that I can use to try to fix it?

Regards, Marcelo.

AmarOk1412 commented 3 years ago

Yeah setting the default value in the configure is correct.

We observed this behaviour only on iPhone devices via the profiler directly on the whole app. So, no I don't think you will get it on a PC (macOS doesn't seems to be impacted and I can't really provide a minimal code). I don't own any iphone so it's from a distant investigation with a dev. I can ping her to come here.

If you need more details:

Thank you for your prompt answer, Regards,

katekm commented 3 years ago

Hi, Issue is still present on iPhone and could be triggered by locking/unlocking the screen. Tested with pupnp 1.14.7 with --disable-reuseaddr and without. Also tested with pupnp 1.12.1. It caused by a while loop inside RunMiniServer. select() does not return an error but returns right away without blocking.

tguillem commented 10 months ago

Hello, it should be fixed by https://github.com/pupnp/pupnp/pull/428 (I didn't know there was an issue)