cocos2dx js 3.3, android crash issues summary

It’s my first cocos2dx js project, and faced a lot of crash in Android. Here is the summary, hope will help someone.

  1. var object was freed by js GC, but it is still needed in cc object(crashed on both Android and ios):
    We have a ScrollViewHelper, it is a js Object, and listen for a scrollview’s event, use this not var to refs the variable

Right:
this.helper = new ScrollViewHelper();
Wrong:
var helper = new ScrollViewHelper();
(js GC will free helper,scrollview event will cause a crash)

  1. load remote picture timeout crash
    Document is here: http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTNOSIGNAL
    Fix for Curl crash in case there is a network timeout

Fix:
add code to Downloader:prepareHeader:
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);

  1. Random GC crash, not know the exact reason.
    I called garbagecollect manually, and there are some 100% crash steps, but I can’t find why. I fixed it by set armature or ccb animation complete callback to null when not needed it.

Attention(ccb animation set null, only need one null, two null will cause "null is not a function " error):
Right:
ccbNode.animationManager.setCompletedAnimationCallback(null);
Wrong
ccbNode.animationManager.setCompletedAnimationCallback(null, null);


There are still some GC crash in my game, if I called garbagecollect every 0.5s. And I don’t know the reason.