-
Notifications
You must be signed in to change notification settings - Fork 486
cc.textureCache.addImageAsync caused crash on Android, iOS, Mac #1658
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
Comments
Delayed to v3.7 |
Is there any temporarily solution for this issue? Thanks. |
is this fixed yet? I can't get it to work on 3.6, is there any quick fix for this? if there isn't, maybe I have to rollback to 3.3 where it works. here is my stack trace signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000 |
this is a serious bug. anybody has a workaround for it while we wait for the official fix? |
Yes, this is a critical bug but been delayed to fix from v3.6 to v3.7. It looks like TextureCache::addImageAsync has more issue on Cocos2d-x For temporarily solution, i make the downloader become sync which has the old time app freeze issue. void __JSDownloaderDelegator::download(JSContext *cx, JS::HandleObject obj, const std::string &url, JS::HandleValue callback) |
Maybe I have fixed this issue. Modify the file at /frameworks/js-bindings/bindings/manual/extension/jsb_cocos2dx_extension_manual.cpp
Ok, it works now! |
@pwang08 Thanks. |
@Zinitter I have start a thread to process, so the solution works well. |
@pwang08 Between, have you test it with this code which call addImageAsync multiple times or try to load same url?
|
Hi, all I finally created a proper PR for fixing this issue. This PR have refactored __JSDownloadDelegate for multithread. In fact, the core issue is that the creations and manipulations of js objects and values in |
Thanks for the fixed. I tried the code and compile for Mac but got error. void __JSDownloaderDelegator::startDownload() is not declare on jsb_cocos2dx_extension_manual.h |
It passed Jenkins CI now, and you can see the declaration of startDownload here: |
Good job! But there is still a freeze issue on Android and iOS which cause by Image::initWithImageData as we discussed before. So I would like to request a feature which make the Image::initWithImageData become async in Android and iOS. Thanks for your effort! |
@Zinitter But By the way, can you help me review the logic of my solution ? |
I tested the code with my project which might call cc.textureCache.addImageAsync to load image with url at the same time.
Using same image url would not crash the app and able to download the image and create the sprite. But I realised that there is slightly freeze when the callback "this.downloadCompleted" is called when success. I tried with 2 cases on the callback and both case have the freeze issue.
So far in my testing, the app only crashed once. The callback is called with texture = null as show in log. I'm not very sure how that happen, but these are the steps i tested with. Step 1
Step 2 Hope these help. I have another request, can we make cc.RenderTexture.saveToFile async so that when cc.textureCache.addImageAsync downloaded the image, then i can cache the image by save it to a file.
Or do we have other way to cache the image so when we reopen the app, we don't need to download the image again. Thanks. |
Thank you very much for the test ! I will look into it
I think it's more proper to directly download the file and store them in user device. For now the implementation of JSDownloadDelegate is downloading via a buffer, but |
How about implementation like this For download and use (current implementation)
For download to file and use
The path to store the file by default is either
User can change the default storage path if they want. Assume we downloading multiple files at the same time, i'm curious if directly download the file and store them, then straight load from the file and create a sprite, would it have the frozen issue or the time needed to process as we don't preload the resources. Thanks. |
I agree with the basic idea, but I'm afraid we won't have time to implement it very soon, because it requires an API change, we take such change very seriously Some problem:
That will violate end user's storage, because all cocos applications will save in the same folder by default.
I think it should be occupied by |
I'm understand that Cocos team are very busy recently. Does the If not, do you have any temporarily solution for cc.RenderTexture.saveToFile or cc.textureCache.downloadImageAsync to avoid the frozen issue? Cocos2d-JS is lack of multi-threading which fully utilise multi core cpu and avoid the frozen issue on coding. Cocos team should implement something to handle the multi threading issue for Cocos2d-JS. About the storage, i don't know that will violate end user's storage. But it should not a problem to defined by developer who want to use the feature. Thanks. |
cocos2d/cocos2d-js#1658: Fix js_load_remote_image issue with multithread
I still got crash after apply this commit cocos2d/cocos2d-x@fdec552 when offline |
Crash happen on Android, iOS, Mac. Win32 not tested.
Crash on JSAutoCompartment ac(_cx, _obj.ref() ? _obj.ref() : global);
Tested with code below :
#1507 (comment)
Updated : update issues
The text was updated successfully, but these errors were encountered: