Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Expose is_servo_internal for gc outside about scope#45032

Open
janeoa wants to merge 4 commits into
servo:mainfrom
janeoa:optionaly-expose-gc
Open

Expose is_servo_internal for gc outside about scope#45032
janeoa wants to merge 4 commits into
servo:mainfrom
janeoa:optionaly-expose-gc

Conversation

@janeoa
Copy link
Copy Markdown
Contributor

@janeoa janeoa commented May 20, 2026

More context in the #44878. But generally. I wanted to be able to run

navigator.servo.garbageCollectAllContexts()

In the blink-perf-test's runner.js so that it does not use the strange fallback method.

function gcRec(n) {
     if (n < 1)
         return {};
     var temp = {i: "ab" + i + (i / 100000)};
     temp += "foo";
     gcRec(n-1);
 }
 for (var i = 0; i < 1000; i++)
     gcRec(10);

So now, this PR introduces --pref dom_servo_gc_enabled=true
That makes is_servo_internal in the components/script/dom/servointernals.rs to return true, so that the navigator.servo.garbageCollectAllContexts() could be called outside the about:memory url.

Testing: To test, I've locally put a print! in the fn GarbageCollectAllContexts(&self) that is in the components/script/dom/servointernals.rs and run the servo with and without the --pref dom_servo_gc_enabled=true. As expected, the print! worked only when the correct --pref is present.

Fixes: #44878

@janeoa janeoa requested a review from gterzian as a code owner May 20, 2026 13:45
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 20, 2026
@Narfinger Narfinger assigned Narfinger and unassigned Narfinger May 20, 2026
@Narfinger
Copy link
Copy Markdown
Contributor

Does this enable other features if we are privileged?

@webbeef
Copy link
Copy Markdown
Contributor

webbeef commented May 21, 2026

Does this enable other features if we are privileged?

Yes, all the methods of the ServoInternals interface.

@Narfinger
Copy link
Copy Markdown
Contributor

@janeoa I think then the pref should be called something like: "expose_servointernals_globally"

@janeoa janeoa force-pushed the optionaly-expose-gc branch from 8e31579 to c86fb82 Compare May 21, 2026 08:37
Comment thread components/config/prefs.rs Outdated
@servo-highfive servo-highfive added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 21, 2026
@Narfinger
Copy link
Copy Markdown
Contributor

Just small nits, otherwise looks good to me!

Co-authored-by: Narfinger <[email protected]>
Signed-off-by: Asset Malik <[email protected]>
@servo-highfive servo-highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optionally exposing navigator.servo.garbageCollectAllContexts() outside about:... url scope for testing reasons

4 participants