Skip to content

Attach PipelineId to all ScriptMsg #17201

Closed

Description

@paulrouget

Many ScriptMsg already require a PipelineId field.

Many of these messages are sent to the constellation to be then sent to the embedder via the compositor (status, favicon, loadcomplete, loadstate, etc). And as of now, the decision to send the message to the embedder (which usually is either the pipeline the top level one or not) is done in on of these 3 places: in /script/, in compositor.rs, or in constellation.rs.

I think the logic of forwarding the event or not should all happen in constellation.rs. The constellation has more context than /script/, and we eventually want to get rid of the compositor step (#15934).

For the constellation to make the correct decision of forwarding the event, it needs the PipelineId.

I'm looking for a way to easily attach the PipelineId to all the ScriptMsg.

I was thinking about change the ScriptMsg type to:

struct ScriptMsg {
  source: PipelineId,
  message: ScriptMsgContent,
}

enum ScriptMsgContent {
  SetPageTitle,
  Focus,
  …
}

… but it's kind of cumbersome. And we don't always have an easy access to the pipeline_id. Would there be a better way to do that?

Activity

  1. self-assigned this
    on Jun 7, 2017
  2. paulrouget commented on Jun 7, 2017

    @paulrouget
    ContributorAuthor

    I want also thinking about creating a struct CompositorChannel:

    struct CompositorChannel {
      sender: IpcSender<ScriptMsg>,
      pipeline_id: PipelineId,
    }
    
    impl CompositorChannel {
      fn send(msg) {
        self.sender.send((self.pipeline_id, msg)),
      }
      fn clone_with_new_pipeline(pipeline_id) -> CompositorChannel {
        CompositorChannel {
          pipeline_id: pipeline_id,
          send: self.sender.clone(),
        }
      } 
    }

    … and instead of calling constellation_chan.clone() we would use constellation_chan.clone_with_new_pipeline(pipeline_id).

  3. asajeffrey commented on Jun 7, 2017

    @asajeffrey
    Contributor

    Do you mean:

       struct CompositorChannel {
          sender: Sender<(PipelineId, ScriptMsg)>,
          pipeline_id: PipelineId,
       }

    If so, apart from the naming, this seems sensible. I used a similar trick in worklets:

    /// An executor of worklet tasks

  4. paulrouget commented on Jun 8, 2017

    @paulrouget
    ContributorAuthor

    oops, yes, it's what I meant.

    Thanks.

  5. added
    C-assigned
    on Jun 8, 2017
  6. added 2 commits that reference this issue on Aug 12, 2017
  7. paulrouget commented on Aug 15, 2017

    @paulrouget
    ContributorAuthor

    Fixed by #17425

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-embeddingC-assigned

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions