Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20397] iOS: Main-Thread: Proxies become nil if not created with pageContext

GitHub Issuen/a
TypeStory
PriorityCritical
StatusClosed
ResolutionDone
Resolution Date2016-08-04T02:52:07.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.4.0
ComponentsiOS
Labelsios, mainthread
ReporterHans Knöchel
AssigneeHans Knöchel
Created2016-02-13T13:31:08.000+0000
Updated2016-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.

Comments

  1. Hans Knöchel 2016-03-11

    [~penrique] ping! As far as I understood, we need to init all proxies with initWithPageContext, otherwise it's causing the warning Creating \[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?
  2. Hans Knöchel 2016-03-15

    Related to TIMOB-20396, but we should still replace all \[\[TiBlob alloc] initWithXXXX]] occurrences with a proper page context initialization.
  3. Hans Knöchel 2016-03-16

    PR: https://github.com/appcelerator/titanium_mobile/pull/7854

JSON Source