Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default don't invoke log to javascript in JSC #1687

Merged
merged 1 commit into from Feb 25, 2019

Conversation

Projects
None yet
2 participants
@drelaptop
Copy link
Contributor

drelaptop commented Feb 25, 2019

fix #1617

can't use built-in console.log in JavaScriptCore, exist potential crash in iOS
refer to: https://stackoverflow.com/questions/19649932/javascriptcore-console-log

JavaScriptCore don't promise us built-in console.log works

@dumganhar

This comment has been minimized.

Copy link
Contributor

dumganhar commented Feb 25, 2019

调用系统的 console.log 是为了在远程调试的时候输出到 safari。
建议通过一个宏来控制,默认关闭,有用 safari 远程调试的时候手动打开。

@drelaptop

This comment has been minimized.

Copy link
Contributor Author

drelaptop commented Feb 25, 2019

好的,我改一下

@drelaptop drelaptop force-pushed the drelaptop:v2.0-context2d-bug branch from 14649e4 to 15a1e63 Feb 25, 2019

@drelaptop

This comment has been minimized.

Copy link
Contributor Author

drelaptop commented Feb 25, 2019

please review @dumganhar

@drelaptop drelaptop changed the title can't use built-in console.log in JSC, exist potential crash default don't invoke log to javascript in JSC Feb 25, 2019

@dumganhar

This comment has been minimized.

Copy link
Contributor

dumganhar commented Feb 25, 2019

@drelaptop approved

@dumganhar

This comment has been minimized.

Copy link
Contributor

dumganhar commented Feb 25, 2019

原因可能是:__oldConsoleLog 等 old 对象被 GC 了,但是因为我们通过 getProperty 保存为全局变量,但是却没有 root 组,所以,获取的时候,对 __oldConsoleLog 的 Object 进行 root 即可。

@dumganhar

This comment has been minimized.

Copy link
Contributor

dumganhar commented Feb 25, 2019

update: 不是我上一条的问题:

void jsToSeValue(JSContextRef cx, JSValueRef jsValue, Value* data)
    {
......
        else if (JSValueIsObject(cx, jsValue))
        {
            JSValueRef exception = nullptr;
            JSObjectRef jsobj = JSValueToObject(cx, jsValue, &exception);
            if (exception != nullptr)
            {
                ScriptEngine::getInstance()->_clearException(exception);
            }
            else
            {
                void* nativePtr = internal::getPrivate(jsobj);
                Object* obj = nullptr;
                if (nativePtr != nullptr)
                {
                    obj = Object::getObjectWithPtr(nativePtr);
                }

                if (obj == nullptr)
                {
                    obj = Object::_createJSObject(nullptr, jsobj);
                }
                data->setObject(obj, true); // James: 这里已经 root 了,所以全局的 se::Value 也是 root object的。
                obj->decRef();
            }
        }
        else
        {
            SE_ASSERT(false);
        }
    }

@drelaptop drelaptop merged commit 2235031 into cocos-creator:v2.0-release Feb 25, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.