[TIMOB-20397] iOS: Main-Thread: Proxies become nil if not created with pageContext
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | Critical |
Status | Closed |
Resolution | Done |
Resolution Date | 2016-08-04T02:52:07.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 5.4.0 |
Components | iOS |
Labels | ios, mainthread |
Reporter | Hans Knöchel |
Assignee | Hans Knöchel |
Created | 2016-02-13T13:31:08.000+0000 |
Updated | 2016-08-04T02:52:07.000+0000 |
Description
This issue occurs in several cases when we want to use a proxy (like TiBlob and TiUILivePhoto) and running on main-thread. The usual warning is
\[WARN\] Creating \[object TiBlob\] in a different context than the calling function.
. Example:
Ti.Media.openPhotoGallery({
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO],
success: function(e) {
Ti.API.warn(e.mediaType);
Ti.API.warn(e.media);
}
});
var win = Ti.UI.createWindow({backgroundColor: "#fff"});
win.open();
It is caused because we create a blob using TiBlob *media = \[\[\[TiBlob alloc\] initWithImage:resultImage\]\];
instead of using the page context:
TiBlob *media = [[[TiBlob alloc\] _initWithPageContext:[self pageContext]] autorelease];
[media setImage:resultImage];
This issue effects TIMOB-19666 and possibly many other proxies that have not been tested, yet. We need to make sure that the proxies are created properly and write unit tests to ensure their integrity.
[~penrique] ping! As far as I understood, we need to init all proxies with
initWithPageContext
, otherwise it's causing the warningCreating \[object <TheProxy>\] in a different context than the calling function
. So should we search all matching inits and migrate them, or is there a smarter solution that could do that automatically? And why does the warning occur only on the main thread?Related to TIMOB-20396, but we should still replace all
\[\[TiBlob alloc] initWithXXXX]]
occurrences with a proper page context initialization.PR: https://github.com/appcelerator/titanium_mobile/pull/7854