views:

1664

answers:

2

I have an application that is based on Web 2.0 technologies -- basically I use phonegap / titanium approach to start up a web browser where most of the app is written in javascript and HTML (jQuery, to more precise). The app works great on the emulator, but when I launch it on the G1, it crashes. When I reduce the amount of javascript that has been written for the app, it starts to work again. Alternatively, if I remove the javascriptInterface to access some of the "java" based methods, the app also works.

When I try to load all the javascript and java objects required for the app, it crashes (as in the log below). Is there some hard limit on the amount of "code" memory that I can load in Webkit? The crazy thing is that this app uses a lot of images, that load just fine.. seems like i'm hitting some limit on the number of lines of javascript that I am allowed to parse and load into Webkit ? It does say something about "Too many open files", which might be the issue, but I'm not actually opening any files with my application, so I'm confused by this error.

Thanks for any help. I've been struggling with this for the last few days.

Best.

Alex

07-03 16:43:23.430: DEBUG/dalvikvm(104): GC freed 964 objects / 41632 bytes in 285ms 07-03 16:43:24.030: DEBUG/dalvikvm(314): GC freed 710 objects / 23680 bytes in 131ms 07-03 16:43:24.380: INFO/ActivityManager(62): Process android.process.im (pid 220) has died. 07-03 16:43:24.650: DEBUG/dalvikvm(104): GC freed 964 objects / 41688 bytes in 154ms 07-03 16:43:24.700: ERROR/IMemory(104): cannot dup fd=1023, size=1048576, err=0 (Too many open files) 07-03 16:43:24.700: ERROR/IMemory(104): cannot map BpMemoryHeap (binder=0x4fe260), size=1048576, fd=-1 (Bad file number) 07-03 16:43:24.820: ERROR/JavaBinder(104): *** Uncaught remote exception! (Exceptions are not yet supported across processes.) 07-03 16:43:24.820: ERROR/JavaBinder(104): java.lang.RuntimeException: No memory in memObj 07-03 16:43:24.820: ERROR/JavaBinder(104): at android.database.CursorWindow.native_init(Native Method) 07-03 16:43:24.820: ERROR/JavaBinder(104): at android.database.CursorWindow.(CursorWindow.java:467) 07-03 16:43:24.820: ERROR/JavaBinder(104): at android.database.CursorWindow.(CursorWindow.java:27) 07-03 16:43:24.820: ERROR/JavaBinder(104): at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:442) 07-03 16:43:24.820: ERROR/JavaBinder(104): at android.database.CursorWindow$1.createFromParcel(CursorWindow.java:445) 07-03 16:43:24.820: ERROR/JavaBinder(104): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:95) 07-03 16:43:24.820: ERROR/JavaBinder(104): at android.os.Binder.execTransact(Binder.java:287) 07-03 16:43:24.820: ERROR/JavaBinder(104): at dalvik.system.NativeStart.run(Native Method)

A: 

I would set a breakpoint right about where you think android.process.im dies and single stepping until you get your crash to isolate the bug.

My guess is that the process dies and something happens that causes a cascade of errors because the process no longer exists to handle the error ('cannot dup/too many open files', 'Uncaught remote exception! (Exceptions are not yet supported ACROSS PROCESSES').

Will
+1  A: 

Turn out to be somewhat unrelated to javascript. I was loading too many contacts at once from within java, and exposing this large JSON object across the javascript bridge caused the memory issue. In other words when I have 1000 contacts things break; which 10 contacts everything was fine -- i thought it was something specific to the g1, since the problem didn't show up in the emulator; but I had overlooked the other number of contacts.