Skip to content

embedder_traits: Move Wakelock trait to Embedder_traits#44343

Merged
jdm merged 2 commits into
servo:mainfrom
rovertrack:issue-44239
Apr 25, 2026
Merged

embedder_traits: Move Wakelock trait to Embedder_traits#44343
jdm merged 2 commits into
servo:mainfrom
rovertrack:issue-44239

Conversation

@rovertrack

Copy link
Copy Markdown
Contributor

Moved the Wakelock trait from wakelock to embedder_trait components/shared/embedder/lib.rs
Added Required dependency in components/shared/embedder/lib.rs
imported the Wakelock trait from components/shared/embedder/lib.rs to components/wakelock/lib.rs
Added dependency embedder_trait components/wakelock/Cargo.toml

Testing: All expected test pass as there is no change in flow of working

Fixes: #44239

@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 19, 2026
@jdm jdm changed the title Move Wakelock trait to Embedder_traits embedder_traits: Move Wakelock trait to Embedder_traits Apr 19, 2026
Comment thread components/wakelock/lib.rs Outdated
@mrobinson

Copy link
Copy Markdown
Member

Additionally, before exposing these to the API, a WakeLockDelegate should be exposed and not the WakeLockProvider directly or the WakeLockProvider should be structured and named like the other delegates. In either case, NoOpWakeLockProvider should be probably renamed to DefaultWakeLockDelegate like the other delegates.

Signed-off-by: Rover track <rishan.pgowda@gmail.com>
@rovertrack

Copy link
Copy Markdown
Contributor Author

@mrobinson how to know the methods to be implemented in the WakeLockDelegate other than the WakeLockProvider?
Thanks

@jdm

jdm commented Apr 21, 2026

Copy link
Copy Markdown
Member

Additionally, before exposing these to the API, a WakeLockDelegate should be exposed and not the WakeLockProvider directly or the WakeLockProvider should be structured and named like the other delegates. In either case, NoOpWakeLockProvider should be probably renamed to DefaultWakeLockDelegate like the other delegates.

@mrobinson Actually, I'm not sure if these changes make sense here. The wakelock implementation is a bit different, because the acquire/release operations from the trait take place after the embedder has already approved or denied the request. The trait represents a platform/hardware-specific abstraction over the wakelock feature, and I don't know if changing the naming to match the Delegate concept we use in the embedder API makes sense.

@mrobinson

Copy link
Copy Markdown
Member

@mrobinson Actually, I'm not sure if these changes make sense here. The wakelock implementation is a bit different, because the acquire/release operations from the trait take place after the embedder has already approved or denied the request. The trait represents a platform/hardware-specific abstraction over the wakelock feature, and I don't know if changing the naming to match the Delegate concept we use in the embedder API makes sense.

Is the idea that the WakeLockProvider will be exposed to the embedder? If not, I agree it doesn't matter too much what we call it. It does seem like we want to expose this kind of flexibility to the embedder, even if we have a default implementation like we do with the clipboard.

If it will be exposed though, it seems very similar to the GamepadProvider which serves as glue between libservo and the platform's hardware interface. If these things aren't called Delegates, what should they be called and how should we explain the distinction between what should be a Delegate and what should be the other thing?

@jdm

jdm commented Apr 21, 2026

Copy link
Copy Markdown
Member

Fair enough, assuming you're talking about GamepadDelegate. I think that's a useful comparison.

@mrobinson

Copy link
Copy Markdown
Member

Fair enough, assuming you're talking about GamepadDelegate. I think that's a useful comparison.

Heh. Oh yeah. I meant the GamepadDelegate. If we end up having many of these kind of delegates though, perhaps it would make sense to consider some other kind of API design to organize them all or to place them into some kind of combined platform integration data structure.

@webbeef

webbeef commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Overall this kind of platform specific implementations could be grouped under a "Platform Abstraction Layer" umbrella. What you put here and not, and what makes sense to override by embedders is not always obvious.

For WakeLocks I have a hard time thinking that an embedder could need to override the default platform implementation. On the other hand, something like geolocation has valid use cases for custom implementations.
We don't allow customization of the WebBluetooth platform specific code, but we do for Clipboard and Gamepad... we are already inconsistent!

If we don't want the Servo struct builder itself to end up with lots of configuration options, we could group them all under a PAL trait with a default implementation, and let embedders change any of them. The main drawback would be the increase of public API surface.

@mrobinson

Copy link
Copy Markdown
Member

There is already prior art in this area as well: https://webkit.org/wpe/

@rovertrack

Copy link
Copy Markdown
Contributor Author

so finally the moving of wakelock trait to embedder_trait would be work done for constellation, for the exposing part a new wake_lock_delegate.rs will be added! is this ok @mrobinson, @jdm?

Signed-off-by: Rover track <rishan.pgowda@gmail.com>
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Apr 25, 2026
@jdm jdm added this pull request to the merge queue Apr 25, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 25, 2026
Merged via the queue into servo:main with commit b768a93 Apr 25, 2026
30 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embedder wakelock trait belongs in embedder_traits

5 participants