Merge ~peat-new/repowerd:synchronous-unity-dbus-call into repowerd:master

Proposed by Ratchanan Srirattanamet
Status: Merged
Merge reported by: Alexandros Frantzis
Merged at revision: not available
Proposed branch: ~peat-new/repowerd:synchronous-unity-dbus-call
Merge into: repowerd:master
Diff against target: 23 lines (+2/-3)
1 file modified
src/adapters/unity_display.cpp (+2/-3)
Reviewer Review Type Date Requested Status
Alexandros Frantzis Approve
Review via email: mp+314292@code.launchpad.net

Commit message

adaptors: make the screen-on call to u-s-c synchronous

Normally, repowerd calls the unity-screen-compositor to unblank the
screen via DBus asynchronously before incrementally increase the
brightness. The problem is that, on some device (such as Fairphone 2),
the brightness is ignored if the screen is blanked. So, there is a race
condition between the brightness is incremented to the max and the
screen being actually unblanked.

This commit makes this call synchronous, making sure that the screen will
be unblanked completely before the brightness is set.

Description of the change

adaptors: make the screen-on call to u-s-c synchronous

Normally, repowerd calls the unity-screen-compositor to unblank the
screen via DBus asynchronously before incrementally increase the
brightness. The problem is that, on some device (such as Fairphone 2),
the brightness is ignored if the screen is blanked. So, there is a race
condition between the brightness is incremented to the max and the
screen being actually unblanked.

This commit makes this call synchronous, making sure that the screen will
be unblanked completely before the brightness is set.

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Thanks for the patch.

Making the call synchronous as you propose has the side effect that if the system compositor blocks for whatever reason, it will also block repowerd for the default dbus timeout which is rather long (25 seconds).

I am considering making the call synchronous with a shorter, 1 second timeout, so even if the compositor has entered a problematic state, it won't block repowerd for more than 1 second.

Unfortunately I don't have a fp2 to try this out. Could you check if a 1 second timeout is enough for the fp2?

review: Needs Information
a8f4e85... by Ratchanan Srirattanamet

adaptors: make the screen-on call to u-s-c synchronous

Normally, repowerd calls the unity-screen-compositor to unblank the
screen via DBus asynchronously before incrementally increase the
brightness. The problem is that, on some device (such as Fairphone 2),
the brightness is ignored if the screen is blanked. So, there is a race
condition between the brightness is incremented to the max and the
screen being actually unblanked.

This commit makes this call synchronous, making sure that the screen will
be unblanked completely before the brightness is set. A small timeout of
1 second is added to prevent unity-screen-compositor from blocking
repowerd for too long.

Revision history for this message
Ratchanan Srirattanamet (peat-new) wrote :

> I am considering making the call synchronous with a shorter, 1 second timeout,
> so even if the compositor has entered a problematic state, it won't block
> repowerd for more than 1 second.
>
> Unfortunately I don't have a fp2 to try this out. Could you check if a 1
> second timeout is enough for the fp2?

Sorry for the delay. I've tested 1-second timeout on FP2 and it seems to work fine. So, I've updated the patch for that timeout and also rebase it on current master.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Thanks for the updated patch. I have merged it into repowerd master.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/adapters/unity_display.cpp b/src/adapters/unity_display.cpp
2index 057c0d9..e89435f 100644
3--- a/src/adapters/unity_display.cpp
4+++ b/src/adapters/unity_display.cpp
5@@ -82,7 +82,7 @@ void repowerd::UnityDisplay::turn_on(DisplayPowerControlFilter filter)
6
7 log->log(log_tag, "turn_on(%s)", filter_str.c_str());
8
9- g_dbus_connection_call(
10+ g_dbus_connection_call_sync(
11 dbus_connection,
12 unity_display_bus_name,
13 unity_display_object_path,
14@@ -91,8 +91,7 @@ void repowerd::UnityDisplay::turn_on(DisplayPowerControlFilter filter)
15 g_variant_new("(s)", filter_str.c_str()),
16 nullptr,
17 G_DBUS_CALL_FLAGS_NONE,
18- -1,
19- nullptr,
20+ /* timeout_msec */ 1000,
21 nullptr,
22 nullptr);
23 }

Subscribers

People subscribed via source and target branches