Skip to content

Lift execution context management out of Runtime#43063

Closed
motiz88 wants to merge 1 commit into
facebook:mainfrom
motiz88:export-D53759776
Closed

Lift execution context management out of Runtime#43063
motiz88 wants to merge 1 commit into
facebook:mainfrom
motiz88:export-D53759776

Conversation

@motiz88

@motiz88 motiz88 commented Feb 16, 2024

Copy link
Copy Markdown
Contributor

Summary:
Changelog: [Internal]

Moves the responsibility for managing CDP execution contexts out of the Runtime and into the Instance.

This includes the responsibilities to:

  1. Assign execution context IDs/names
  2. Emit events when execution contexts are created/destroyed
  3. Route CDP messages to the correct Runtime

Re 1: We currently assign a constant execution context ID, which diverges from V8's implementation but is in line with what Hermes has done so far. I'll follow up separately to assign (locally) unique IDs, since this diff is long enough already.

Re 3: Right now, the message routing responsibility is mostly theoretical: only one Runtime exists at a time and "routing" can be done by RuntimeAgent simply deciding whether or not to act on a message (since it receives all messages by default and knows its own ExecutionContextDescription). True multi-Runtime / multi-context support is firmly a future concern, and we can revisit this ( = probably hoist more logic into Instance) when we get there.

In the ExecutionContextNotifications integration test we can see that a few minor bugs in the current Hermes-based implementation are fixed, and also that execution context management is now engine-agnostic (so we can use JsiIntegrationPortableTest instead of JsiIntegrationHermesTest).

Reviewed By: huntie

Differential Revision: D53759776

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 16, 2024
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D53759776

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D53759776

@analysis-bot

analysis-bot commented Feb 16, 2024

Copy link
Copy Markdown
Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 17,836,527 +8,193
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 21,194,981 +8,178
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: eca78c3
Branch: main

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D53759776

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D53759776

@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D53759776

Summary:

Changelog: [Internal]

Moves the responsibility for managing CDP execution contexts out of the Runtime and into the Instance.

This includes the responsibilities to:
1. Assign execution context IDs/names
2. Emit events when execution contexts are created/destroyed
3. Route CDP messages to the correct Runtime

**Re 1:** We currently assign a *constant* execution context ID, which diverges from V8's implementation but is in line with what Hermes has done so far. I'll follow up separately to assign (locally) unique IDs, since this diff is long enough already.

**Re 3:** Right now, the message routing responsibility is mostly theoretical: only one Runtime exists at a time and "routing" can be done by RuntimeAgent simply deciding whether or not to act on a message (since it receives all messages by default and knows its own `ExecutionContextDescription`). True multi-Runtime / multi-context support is firmly a future concern, and we can revisit this ( = probably hoist more logic into Instance) when we get there.

In the `ExecutionContextNotifications` integration test we can see that a few minor bugs in the current Hermes-based implementation are fixed, and also that execution context management is now engine-agnostic (so we can use `JsiIntegrationPortableTest` instead of `JsiIntegrationHermesTest`).

Reviewed By: huntie

Differential Revision: D53759776
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D53759776

@github-actions

Copy link
Copy Markdown

This pull request was successfully merged by @motiz88 in e34e7d7.

When will my fix make it into a release? | Upcoming Releases

@github-actions github-actions Bot added the Merged This PR has been merged. label Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants