Skip to content

Conversation

@julapy
Copy link

@julapy julapy commented Jan 9, 2025

hi, in order to run JSGlobalContextSetInspectable there needs to be check around it for iOS 16.4

        if (@available(iOS 16.4, *)) {
            JSGlobalContextSetInspectable(globalContext, m_options.EnableDebugger);
        }

i noticed that AppRuntime_iOS.mm was calling RunEnvironmentTier in AppRuntime_JavaScriptCore.cpp
however because its inside a cpp file, @available syntax was not allowed.

ive duplicated the RunEnvironmentTier function and moved it to AppRuntime_iOS.mm where @available check can run.

@julapy
Copy link
Author

julapy commented Jan 9, 2025

on another note, might also be good show how AppRuntime Options can be enabled inside LibNativeBridge, so people can easily enable debugger.

    auto runtimeOptions = Babylon::AppRuntime::Options();
    runtimeOptions.EnableDebugger = true;
    runtime.emplace(runtimeOptions);

Comment on lines +16 to +33
void AppRuntime::RunEnvironmentTier(const char*)
{
auto globalContext = JSGlobalContextCreateInGroup(nullptr, nullptr);

if (@available(iOS 16.4, *)) {
JSGlobalContextSetInspectable(globalContext, m_options.EnableDebugger);
}

Napi::Env env = Napi::Attach(globalContext);

Run(env);

JSGlobalContextRelease(globalContext);

// Detach must come after JSGlobalContextRelease since it triggers finalizers which require env.
Napi::Detach(env);
}

Copy link
Contributor

@bghgary bghgary Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the slow response.

RunEnvironmentTier cannot be here as this function is intended to be JS environment specific. I think we need to add some platform specific macros to this code to ensure we don't call this function when it's not available. Availability.h has defines that we can check. Maybe also add a macro to disable this completedly in case someone is building against a version of JSC without this function.

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.

2 participants