Skip to content

FxR: can't load servo twice #22039

Closed
Closed

Description

@paulrouget

The second time Servo is loaded, the script thread panic (not backtrace yet).

Activity

  1. added
    I-panic
    on Oct 29, 2018
  2. paulrouget commented on Oct 30, 2018

    @paulrouget
    ContributorAuthor

    Failing unwrap:

    let runtime = RustRuntime::new().unwrap();

  3. paulrouget commented on Oct 30, 2018

    @paulrouget
    ContributorAuthor

    Well. Apparently we can't work around that: servo/rust-mozjs#442

    We should only shutdown the JS runtime (and the constellation really) only once, but the fact the constellation is hardwired to one compositor makes it difficult.

    So we can either:

    • not shutdown the JS runtime between sessions, not sure if it's possible when the constellation and the whole world is dropped
    • fix the dependency on the compositor (which is an ongoing work, but will take some time) and only unload servo when the app exits
  4. jdm commented on Oct 30, 2018

    @jdm
    Member

    I would be fine with making the actual JS engine shutdown a build feature in rust-mozjs (enable the feature to skip this code). We could enable the feature for android builds to avoid the problem you're having.

  5. paulrouget commented on Oct 31, 2018

    @paulrouget
    ContributorAuthor

    Getting this assertion:

    Assertion failure: cx->runtime()->hasInitializedSelfHosting()
    (Must call JS::InitSelfHostedCode() before creating a global), at mozjs_sys-0.61.2/mozjs/js/src/jsapi.cpp:1978
    
  6. paulrouget commented on Oct 31, 2018

    @paulrouget
    ContributorAuthor

    The change I made to rust-mozjs:

    -            if OUTSTANDING_RUNTIMES.fetch_sub(1, Ordering::SeqCst) == 1 {
    -                PARENT.store(ptr::null_mut(), Ordering::SeqCst);
    -                SHUT_DOWN.store(true, Ordering::SeqCst);
    -                JS_ShutDown();
    -            }
    +            // if OUTSTANDING_RUNTIMES.fetch_sub(1, Ordering::SeqCst) == 1 {
    +            //     PARENT.store(ptr::null_mut(), Ordering::SeqCst);
    +            //     SHUT_DOWN.store(true, Ordering::SeqCst);
    +            //     JS_ShutDown();
    +            // }

    I confirm that we only go through https://github.com/servo/rust-mozjs/blob/26b270d0447557dc0ee585ee8e0db78bbe6ca399/src/rust.rs#L157-L168 once and that InitSelfHostedCode is called on the 2nd load.

  7. paulrouget commented on Oct 31, 2018

    @paulrouget
    ContributorAuthor

    Script thread logs:

    Starting script thread.
    Waiting for event.
    Got event.
    Processing events.
    Processing event FromConstellation(ConstellationControlMsg::ChangeFrameVisibilityStatus).
    Issuing batched reflows.
    Running script thread.
    Waiting for event.
    Got event.
    Processing events.
    Processing event FromConstellation(ConstellationControlMsg::NavigationResponse).
    ScriptThread: loading https://servo.org/ on pipeline PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(1) }
    
  8. paulrouget commented on Nov 2, 2018

    @paulrouget
    ContributorAuthor

    It might not work because Runtime::new is called from 2 different threads?

  9. jdm commented on Nov 6, 2018

    @jdm
    Member

    The point of Runtime::new is that there's one runtime per thread, so that shouldn't matter. It might be worth modifying rust-mozjs so that it only calls JS_Init once and never calls JS_ShutDown, but it still reinitializes the PARENT runtime.

  10. paulrouget commented on Nov 13, 2018

    @paulrouget
    ContributorAuthor

    @jdm this works: servo/rust-mozjs@master...paulrouget:initonce - but is it the way we want to go?

    With this change we can load/unload Servo without any panic/asserts.

  11. jdm commented on Nov 13, 2018

    @jdm
    Member

    @paulrouget That looks fine to me.

  12. added a commit that references this issue on Nov 19, 2018
    1ac6f43
  13. added a commit that references this issue on Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-panic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions