Commit Graph

23 Commits

Author SHA1 Message Date
Richard Hughes
99df74f0c2 Add API to wait for a device
This allows us to ignore all the delays when the device is emulated, with the
idea being to do dozens of device emulations in the CI tests.

Also, do not call fu_progress_sleep() when the device is emulated.
2023-02-01 09:42:08 +00:00
Richard Hughes
38dfdfd42e Convert FuProgress to a FINAL object
We're not going to subclass this, and making it final saves during startup:

 * 300K calls of fu_progress_get_instance_private()
 * 280K calls of fu_progress_get_step_weighting()
2022-12-11 20:26:15 +00:00
Richard Hughes
7a481183ee trivial: interpolate correctly when the old value is exactly zero 2022-10-27 15:29:32 +01:00
Richard Hughes
6547696efb trivial: Only ignore progress steps when they are all nonzero 2022-10-27 15:29:32 +01:00
Richard Hughes
b50b67107f Add fu_progress_to_string() to make debugging easier 2022-10-27 15:29:32 +01:00
Richard Hughes
5014c87a2a trivial: Remove a condition that can never be non-valid
PVS: A part of conditional expression is always true: priv->children->len > 0.
2022-09-09 19:23:29 +01:00
Gaël PORTAY
2454753cf7 trivial: progress: Fix documentation
This commit cf9ebdb703.
2022-06-20 12:00:40 -04:00
Richard Hughes
87c4163993 trivial: Fix typo when setting the parent status 2022-06-16 19:54:46 +01:00
Richard Hughes
cf9ebdb703 Add startup profiling functionality
Using `sudo FWUPD_PROFILE=10 ./src/fwupd --verbose` will print a
dump of startup times onto the console so that we can debug which
plugin is slowing down system startup. For example:

    ../src/fu-engine.c:5409:plugins-coldplug [108.55ms]:
        ../plugins/amt/fu-plugin-amt.c:437:amt [27.14ms]:
            :create-context [12.66ms]
            :get-version [8.44ms]
            :add-device [3.95ms]
2022-06-14 22:08:02 +01:00
Richard Hughes
2203b3ce7b trivial: gi-docgenize some of the function comments 2022-06-14 14:36:52 -05:00
Richard Hughes
9b29d70f31 Add a progress flag to indicate for when the child returns early
Using `fu_progress_finished(fu_progress_get_child(progress))` is IMHO
a hacky workaround.
2022-06-14 14:31:19 +01:00
Richard Hughes
dc91d59f8e Remove the recently added fu_progress_add_step_full()
Just break API instead.
2022-06-03 13:47:11 -05:00
Richard Hughes
f14e4f8b8d trivial: Do not require an ID to finish a progress object
The function might have returned (possibly with an error set) before
fu_progress_set_id() was called.
2022-06-01 15:05:43 +01:00
Richard Hughes
5ef0ae182d Add a 'name' attribute to each FuProgress step
This allows us to print better warning strings, and in the future
would allow us to profile each operation in a meaningful way.

Also, add context to some of the progress steps as required.
2022-06-01 15:05:43 +01:00
Gaël PORTAY
41cbf8aa18 progress: Inherit status from parent 2022-05-27 11:19:51 -04:00
Richard Hughes
04f00e8a17 trivial: Never return the invalid value from fu_progress_get_percentage() 2022-03-30 18:42:01 +01:00
Richard Hughes
5817ef3b4f Emit 0% in FuProgress to show the child has started
This prevents showing the 'old' percentage until the first sub-task has
completed for some device firmware updates.
2022-03-29 20:04:26 +01:00
Richard Hughes
e17a107ce1 trivial: Cast the g_signal_connect() object to allow static analysis
This is useful when using https://gitlab.freedesktop.org/tartan/tartan
2022-01-03 22:46:23 +00:00
Richard Hughes
2e99055d1e trivial: Add some more annotations for language bindings 2022-01-03 22:46:23 +00:00
Richard Hughes
91dc36cba7 trivial: Don't reset the status when calling fu_progress_finished() 2021-11-27 07:22:50 +00:00
Richard Hughes
fca20c0722 trivial: Fix the progress status when required
When the child has completed we rely on the next fu_progress_step_done()
call to set the status value back to the parent-defined value. In the
case where there is a delay until the next step is done (e.g. waiting
for hardware to re-enumerate) the child status persisted incorrectly.
2021-11-15 14:59:37 +00:00
Richard Hughes
f302bbcb03 trivial: Fix a potential division by zero
Spotted by Coverity.
2021-09-24 19:03:52 +01:00
Richard Hughes
40cd18fa97 Allow using a per-device global percentage completion
It's actually quite hard to build a front-end for fwupd at the moment
as you're never sure when the progress bar is going to zip back to 0%
and start all over again. Some plugins go 0..100% for write, others
go 0..100% for erase, then again for write, then *again* for verify.

By creating a helper object we can easily split up the progress of the
specific task, e.g. write_firmware().

We can encode at the plugin level "the erase takes 50% of the time, the
write takes 40% and the read takes 10%". This means we can have a
progressbar which goes up just once at a consistent speed.
2021-09-13 14:28:15 +01:00