Cocos Creator v1.6.1 内测版发布帖

苹果真机点Editbox闪退的机率在20%,调用栈如下:

0 mimipoker-mobile JS_HasProperty(JSContext*, JS::Handle<JSObject*>, char const*, bool*) + 236
1 mimipoker-mobile JS_HasProperty(JSContext*, JS::Handle<JSObject*>, char const*, bool*) + 60
2 mimipoker-mobile ScriptingCore::executeFunctionWithOwner(JS::HandleJS::Value, char const*, JS::HandleValueArray const&) + 72
3 mimipoker-mobile JSB_EditBoxDelegate::editBoxEditingDidBegin(cocos2d::ui::EditBox*) + 216
4 mimipoker-mobile cocos2d::ui::EditBoxImplCommon::editBoxEditingDidBegin() + 64
5 mimipoker-mobile -[UIEditBoxImplIOS_objc textFieldShouldBeginEditing:] + 116
6 UIKit -[UITextField canBecomeFirstResponder] + 196
7 UIKit -[UIResponder becomeFirstResponder] + 244
8 UIKit -[UIView(Hierarchy) becomeFirstResponder] + 148
9 UIKit -[UITextField becomeFirstResponder] + 64
10 mimipoker-mobile std::__1::function<void (cocos2d::Ref*, cocos2d::ui::Widget::TouchEventType)>::operator()(cocos2d::Ref*, cocos2d::ui::Widget::TouchEventType) const + 48
11 mimipoker-mobile cocos2d::ui::Widget::releaseUpEvent() + 76
12 mimipoker-mobile cocos2d::ui::Widget::onTouchEnded(cocos2d::Touch*, cocos2d::Event*) + 132
13 mimipoker-mobile std::__1::function<void (cocos2d::Touch*, cocos2d::Event*)>::operator()(cocos2d::Touch*, cocos2d::Event*) const + 44
14 mimipoker-mobile _ZNSt3__110__function6__funcIZN7cocos2d15EventDispatcher18dispatchTouchEventEPNS2_10EventTouchEE3$3NS_9allocatorIS6_EEFbPNS2_13EventListenerEEEclEOSA + 300
15 mimipoker-mobile std::__1::function<bool (cocos2d::EventListener*)>::operator()(cocos2d::EventListener*) const + 40
16 mimipoker-mobile cocos2d::EventDispatcher::dispatchEventToListeners(cocos2d::EventDispatcher::EventListenerVector*, std::__1::function<bool (cocos2d::EventListener*)> const&) + 216
17 mimipoker-mobile cocos2d::EventDispatcher::dispatchTouchEvent(cocos2d::EventTouch*) + 364
18 mimipoker-mobile cocos2d::EventDispatcher::dispatchEvent(cocos2d::Event*) + 208
19 mimipoker-mobile cocos2d::GLView::handleTouchesOfEndOrCancel(cocos2d::EventTouch::EventCode, int, long*, float*, float*) + 388
20 mimipoker-mobile -[CCEAGLView touchesEnded:withEvent:] + 500
21 UIKit -[UIWindow _sendTouchesForEvent:] + 2480

如果 editbox component 被 destroy 的话会导致 C++ 层的 delegate 丢失,进而导致回调出错,我会加一个保护

我找到原因了,是因为我在onDisable写了editbox._sgNode.setDelegate(null),因为在onDestroy时对象已经不存在,所以当时写在onDisable,但我这里全改了不再distroy,只active=false,就出问题了,不过总觉得这里也不应该闪退,应该报个脚本错误就好.

我会在 C++ 层保护,如果 delegate 为空,不会调用回调函数

1赞

@dumganhar, 另一个问题:
//this._webSocket 是WebSocket对象.
isConnected: function () {
return (cc.isValid(this._webSocket) && this._webSocket.readyState == WebSocket.OPEN);
},

我把这个isConnected的检查写在update,就容易宕机,调用栈如下,发生在安卓系统,当然我改成cc.sys.isObjectValid应该就OK了:

回报一个蛮神奇的问题:

外层节点放了Layout,ResizeType: Container
里面放了一张图,加上Widget,四个边界 0px
里面再放了一个RichText,

然后调整Layout的 padding,它就会无限增长了 :sweat_smile:

测试项目:( 打开只要改Layout的padding就会重现) cccLayout.zip (48.3 KB)

这个确实有 bug,不过应该是 Layout 跟 widget 的问题,我找找看原因

1赞

谢谢 @Knox 大神 :grin:

layout的type设置一个就没问题了

是,不过我要的效果就是四个方向都有padding

你在layout那个结点上加个sprite然后把这个背景用九宫格.这个layout里面只放一个richtext.richtext这样设置:,
layout这样设置:

大功告成.

谢谢反馈,我们下个版本会修复这个问题。这里 layout 的尺寸是用 widget 算出来的,widget 的尺寸是用 layout 算出来的,所以就死循环了…… 不过这边正常是有报错的…… 后来加了个 padding 没更新错误检测代码,所以就……

1赞

好像这个layout与label的shrink或resize_height模式有类似的冲突,不过我都改变使用方式,略过了,这种算小问题.

目前还是有解决办法的,我只是刚好试到这个问题,就回报一下

不过呢@@,你刚刚这样设置的话,想要padding top/ bottom怎么办?

虽然这些问题都可以写代码处理啦:yum:

哈,这个好办,在最外面包一个node,这个node用widget专门来做padding

现在的处理方法是像你说的,只把Sprite放在layout节点,里面只放一个控件来处理
谢谢你的建议啰

@haroel 已经提交了你想要的修改

https://github.com/cocos-creator/cocos2d-x-lite/pull/776

上面的 PR 也包含你这个需求的修改,现在没有 js delegate 不会再崩溃或者报错

3赞

已果断整合:wink:

我们的苹果版本还剩下这一个Panda兄已经解决过但没有合进来的闪退问题,不过好像问题不大,但我看不顺眼,用了default但我们没改代码.:smile: