Issue
Error when trying to get the events between 2 dates.
To reproduce
1. Run code below
2. Monitor console output i.e. eGomez-MacBook-Pro:platform-tools egomez$ ./adb -d logcat
Repro sequence
var startDate = new Date(2012, 03, 10, 12, 0, 0);
var endDate = new Date(2012, 03, 19, 14, 0, 0);
var out = [];
var calendars = Ti.Android.Calendar.allCalendars;
Ti.API.info('-> '+JSON.stringify(calendars));
for (var i=0; i < calendars.length; i++) {
Ti.API.info('=> '+JSON.stringify(calendars[i]));
var cal_events = calendars[i].getEventsBetweenDates(startDate,endDate);
for (var j=0; j < cal_events.length; j++) {
out.push(cal_events[j]);
};
};
Console output Ti SDK 2.0
=com.appcelerator.com/.T15422Activity }
I/ActivityManager( 1345): Start proc com.appcelerator.com for activity com.appcelerator.com/.T15422Activity: pid=6674 uid=10071 gids={1015, 3003}
I/TiApplication( 6674): (main) [0,0] checkpoint, app created.
I/TiApplication( 6674): (main) [247,247] Titanium 2.0.0 (2012/03/18 15:48 fc5c94a)
I/TiDbHelper( 6674): (main) [2020,2267] No value in database for platform key: 'unique_machine_id' returning supplied default ''
I/TiDbHelper( 6674): (main) [18,2285] No value in database for platform key: 'hardware_machine_id' returning supplied default ''
I/TiApplication( 6674): (main) [197,2482] Titanium Javascript runtime: v8
I/TiRootActivity( 6674): (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
D/TiAnalyticsDb( 6674): (main) [100,100] Creating Database tianalytics.db
I/TiAnalyticsDb( 6674): (main) [227,327] Upgrading Database from 1 to 4
D/WifiStateTracker( 1345): WifiStateTracker.requestConnectionStatus() reply is null init values.
E/TiApplication( 6674): (KrollRuntimeThread) [1972,2299] APP PROXY: ti.modules.titanium.app.AppModule@44a689d8
I/TiAPI ( 6674): -> [{"hidden":false,"id":"1","selected":true,"name":"eduardo.www@gmail.com"}]
I/TiAPI ( 6674): => {"hidden":false,"id":"1","selected":true,"name":"eduardo.www@gmail.com"}
03-19 10:01:22.375: W/System.err(22687): java.lang.NullPointerException
03-19 10:01:22.375: W/System.err(22687): at ti.modules.titanium.android.calendar.EventProxy.queryEventsBetweenDates(EventProxy.java:86)
03-19 10:01:22.375: W/System.err(22687): at ti.modules.titanium.android.calendar.EventProxy.queryEventsBetweenDates(EventProxy.java:210)
03-19 10:01:22.380: W/System.err(22687): at ti.modules.titanium.android.calendar.CalendarProxy.getEventsBetweenDates(CalendarProxy.java:146)
03-19 10:01:22.380: W/System.err(22687): at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
03-19 10:01:22.380: W/System.err(22687): at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:60)
03-19 10:01:22.380: W/System.err(22687): at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:494)
03-19 10:01:22.380: W/System.err(22687): at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:675)
03-19 10:01:22.380: W/System.err(22687): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:392)
03-19 10:01:22.380: W/System.err(22687): at android.os.Handler.dispatchMessage(Handler.java:95)
03-19 10:01:22.380: W/System.err(22687): at android.os.Looper.loop(Looper.java:132)
03-19 10:01:22.380: W/System.err(22687): at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:104)
03-19 10:01:22.390: E/TiJSError(22687): (main) [7740,11480] ----- Titanium Javascript Runtime Error -----
03-19 10:01:22.395: E/TiJSError(22687): (main) [0,11480] - In helpers/calendar_helper.js:62,35
03-19 10:01:22.395: E/TiJSError(22687): (main) [0,11480] - Message: Uncaught Error: Java Exception occurred
03-19 10:01:22.395: E/TiJSError(22687): (main) [0,11480] - Source: var cal_events = calendars[i].getEventsBetweenDates(startDate,endDate);
Opened PR https://github.com/appcelerator/titanium_mobile/pull/1752 to address the source of the error. I was unable to reproduce failure against master. What device and OS version (3.x.x) specifically (also runtime) was this reproduced on?
Device
Galaxy Tab 7 Plus model GT-P6210 Android version 3.2 Kernel 2.6.36-P6210UEKJC-CL567728 se.infra@SEI-20 #3Runtime
V8Closing as Fixed. SDK: 2.0.0.v20120321071752 Android: V8 Studio: 2.0.0.201203202130 OS: Snow Leopard Devices Tested: Droid3 2.3.4, GSlate 3.1, Galaxy Tab 10.1 3.2 Note: Tested on available 3.X devices as per Thomas. Test Code:
Reopening to update labels.
Runtime error occurred as: Uncaught Error: Java Exception occurred Log file "event_exception.txt" is attached. App file is Event_app.txt Tested on: Device : Google Nexus 7, Android Version: 4.1 SDK: 3.1.1.v20130531163723 CLI version : 3.1.0 OS : MAC OSX 10.7.5 Appcelerator Studio, build: 3.1.1.201306012403 XCode : 4.5.1
Ran the test case in Description on Nexus 7 (4.1) with the latest 3.1.1 and it works fine. Ran the attached "Event_app.txt" on Nexus 7 (4.1) with the latest 3.1.1. It crashes with the OutOfMemoryError:
This is because in "Event_app.txt" it appended all the info from 3485 events to ONE string. Modified the code and then it runs without any problem:
Resolve the ticket as Fixed.
Anvil test case added. https://github.com/appcelerator/titanium_mobile/pull/4944
Closing ticket as fixed.