Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (android)
Viewing all articles
Browse latest Browse all 7655

Ti.API.addEventListener causing a libc: Fatal signal 11 (SIGSEV) on Android

$
0
0

Hi - I've now tried this on 2 different workstations and even rebuilt my Titanium on one and tried it again.

I created a new project using the Classic template "Single Window Application". Verified the app runs against my genymotion vm. All looks good.

Titanium Studio, build: 3.2.3.201404181442 Titanium Command-Line Interface, CLI version 3.2.3, Titanium SDK version 3.2.3.GA

Now, I want to use some global event handlers (mostly for navigation events). All works just fine is iOS. Every time I run the app with the following app.js:

/*
 * Single Window Application Template:
 * A basic starting point for your application.  Mostly a blank canvas.
 *
 * In app.js, we generally take care of a few things:
 * - Bootstrap the application with any data we need
 * - Check for dependencies like device type, platform version or network connection
 * - Require and open our top-level UI component
 *
 */
 
//bootstrap and check dependencies
if (Ti.version < 1.8) {
  alert('Sorry - this application template requires Titanium Mobile SDK 1.8 or later');
}
 
Ti.API.info("starting the app");
 
// This is a single context application with multiple windows in a stack
(function() {
  //render appropriate components based on the platform and form factor
  var osname = Ti.Platform.osname,
    version = Ti.Platform.version,
    height = Ti.Platform.displayCaps.platformHeight,
    width = Ti.Platform.displayCaps.platformWidth;
 
  //considering tablets to have width over 720px and height over 600px - you can define your own
  function checkTablet() {
    var platform = Ti.Platform.osname;
 
    switch (platform) {
      case 'ipad':
        return true;
      case 'android':
        var psc = Ti.Platform.Android.physicalSizeCategory;
        var tiAndroid = Ti.Platform.Android;
        return psc === tiAndroid.PHYSICAL_SIZE_CATEGORY_LARGE || psc === tiAndroid.PHYSICAL_SIZE_CATEGORY_XLARGE;
      default:
        return Math.min(
          Ti.Platform.displayCaps.platformHeight,
          Ti.Platform.displayCaps.platformWidth
        ) >= 400;
    }
  }
 
  var isTablet = checkTablet();
  console.log(isTablet);
 
  var Window;
  if (isTablet) {
    Window = require('ui/tablet/ApplicationWindow');
  } else {
    // Android uses platform-specific properties to create windows.
    // All other platforms follow a similar UI pattern.
    if (osname === 'android') {
      Window = require('ui/handheld/android/ApplicationWindow');
    } else {
      Window = require('ui/handheld/ApplicationWindow');
    }
  }
 
  // *** changes from the default template below
  Ti.API.info("global event listener");
  Ti.API.addEventListener("wth", function() {
    Ti.API.debug("event fired - wth");
    alert("wth");
  });
 
  Ti.API.info("and open the window");
  var win = new Window();
  win.addEventListener("open", function() {
    alert("window open");
    Ti.API.info("fire event wth");
    Ti.API.fireEvent("wth");
  });
  win.open();
  // ***  changes from the default template above
})();
The app crashes HARD, and I get the following in the log:
-- Start application log -----------------------------------------------------
[INFO] :   TiApplication: (main) [0,0] checkpoint, app created.
[ERROR] :  Trace: error opening trace file: No such file or directory (2)
[INFO] :   TiApplication: (main) [9,9] Titanium 3.2.3 (2014/04/22 10:17 b958a70)
[INFO] :   TiApplication: (main) [30,39] Titanium Javascript runtime: v8
[INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
[WARN] :   V8Object: Runtime disposed, cannot set property 'userAgent'
[INFO] :   starting the app
[INFO] :   false
[INFO] :   global event listener
[INFO] :   libc: Fatal signal 11 (SIGSEGV) at 0x00000014 (code=1), thread 2930 (KrollRuntimeThr)
Nothing I do makes it work ... cleaning the project, using different Android API levels in genymotion, different Titanium SDK versions, putting the call in a different spot, running it directly on my Galaxy S5 ... no joy.

Even stranger, if I comment out the Ti.API.addEventListener block, I get the following from the Ti.API.fireEvent() running in the window event handler. (at least it isn't a hard segfault)

-- Start application log -----------------------------------------------------
[ERROR] :  Trace: error opening trace file: No such file or directory (2)
[INFO] :   TiApplication: (main) [0,0] checkpoint, app created.
[INFO] :   TiApplication: (main) [7,7] Titanium 3.2.3 (2014/04/22 10:17 b958a70)
[INFO] :   TiApplication: (main) [17,24] Titanium Javascript runtime: v8
[INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
[WARN] :   V8Object: Runtime disposed, cannot set property 'userAgent'
[INFO] :   starting the app
[INFO] :   false
[INFO] :   and open the window
[INFO] :   I/dalvikvm-heap: Grow heap (frag case) to 12.301MB for 1536012-byte allocation
[INFO] :   I/dalvikvm-heap: Grow heap (frag case) to 14.896MB for 2731532-byte allocation
[INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity resume. activity = com.ontoreason.wth.WthActivity@536efcd0
[INFO] :   ALERT: (KrollRuntimeThread) [26,26] window open
[INFO] :   fire event wth
[ERROR] :  TiExceptionHandler: (main) [49,75] ----- Titanium Javascript Runtime Error -----
[ERROR] :  TiExceptionHandler: (main) [0,75] - In ti:/titanium.js:248,26
[ERROR] :  TiExceptionHandler: (main) [0,75] - Message: Uncaught TypeError: Cannot read property '_hasJavaListener' of undefined
[ERROR] :  TiExceptionHandler: (main) [0,75] - Source:      return this._properties[property];
[ERROR] :  V8Exception: Exception occurred at ti:/titanium.js:248: Uncaught TypeError: Cannot read property '_hasJavaListener' of undefined
[WARN] :   EGL_emulation: eglSurfaceAttrib not implemented
[WARN] :   EGL_emulation: eglSurfaceAttrib not implemented
[WARN] :   EGL_emulation: eglSurfaceAttrib not implemented
Anyone have any ideas? At this point I'm giving up and will try a different technique to handle what I was doing with the global handler.

Thanks, Scott


Viewing all articles
Browse latest Browse all 7655


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>