This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

More loading on Android strangeness


I've made more progress on my Android app that loads and executes an
external scheme file (see: http://bit.ly/14KrNLx), but now I'm running
into a fresh set of oddness.

The salient parts of my Android activity code is thus:

 ((onCreate (savedInstance :: Bundle))
  (invoke-special android.app.Activity (this) 'onCreate savedInstance)
  (prep-directories)
  (<kawa.standard.Scheme>:registerEnvironment)
  ((this):do-load "on-create"))

  ((do-load event)
   (let* ((scm (app-doh-path event ".scm")))
     (try-catch
      (parameterize ((current-activity (this)))
        (load scm))
      (ex java.lang.Throwable
          ((this):setContentView
           (android.widget.TextView (this)
                                    text: (exn->string ex)))))))

(Full code: https://github.com/benjisimon/app-doh/blob/master/src/com/benjisimon/appdoh/main.scm)

When I put the following code in the file to be called with (load ...)
all works just fine:

; --------------
(define (logi . messages)
 (android.util.Log:i "on-create.scm" (apply string-append messages)))

(logi "Starting")
(logi "Ending")
; --------------

(That is, the adb log reports the messages "Starting" and "Ending")

However, if I change the above to:

; --------------------
(define (logi . messages)
 (android.util.Log:i "on-create.scm" (apply string-append messages)))

(logi "Starting")

(let ((x (current-activity))) ; ADDED
 (logi "xxx"))

(logi "Ending")
; -------------------------

the results are baffling.  When I invoke ((this):do-load "on-create")
one of two things happens:

a) The phrases "Starting" and "Ending" print, but "xxx" does not.
b) The phrase "Starting" prints followed by a stack trace, followed by
"Ending."' I've put the stack trace at the end of this message to make
this message easier to read.

There doesn't seem to be an obvious pattern when (a) or (b) happens.
I've got a refresh button setup to invoke (this):do-load and I can hit
it a few times in a row and get (a)'s behavior, and then the next
time, I'll get (b)'s and then the time after that I may get (a).

Besides this seemingly random behavior, I've got to wonder:

(1) The parameter (current-activity) doesn't seem to be consistently set. Why?

(2) When the code does execute, it seems to silently ignore the block
involving (current-activity). Why?

(3) I'm catching throwables, yet, the stack trace is being printed out
on System.err, rather than being caught by my code. Why?

Thanks for any assistance you can provide.

That massive stack trace. Note: the stack trace appears to repeat,
however, this is what's shown when I invoke do-load a single time.
Every time I hit refresh, I clear the log.  It almost looks like it's
buffering the error message and the showing them to me all at once.
Regardless, I'm confused :-).

W/System.err(19851):     at gnu.expr.Expression.eval(Expression.java:28)
W/System.err(19851):     at gnu.expr.ApplyExp.apply(ApplyExp.java:141)
W/System.err(19851):     at
gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
W/System.err(19851):     at
gnu.mapping.CallContext.getFromContext(CallContext.java:264)
W/System.err(19851):     at gnu.expr.Expression.eval(Expression.java:28)
W/System.err(19851):     at gnu.expr.LetExp.evalVariable(LetExp.java:24)
W/System.err(19851):     at gnu.expr.LetExp.apply(LetExp.java:57)
W/System.err(19851):     at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:302)
W/System.err(19851):     at gnu.expr.ModuleExp.evalModule(ModuleExp.java:219)
W/System.err(19851):     at kawa.Shell.run(Shell.java:291)
W/System.err(19851):     at kawa.Shell.runFile(Shell.java:523)
W/System.err(19851):     at kawa.standard.load.apply2(load.java:67)
W/System.err(19851):     at kawa.standard.load.apply1(load.java:27)
W/System.err(19851):     at com.benjisimon.appdoh.main.doLoad(main.scm:60)
W/System.err(19851):     at
com.benjisimon.appdoh.main.onOptionsItemSelected(main.scm:47)
W/System.err(19851):     at
android.app.Activity.onMenuItemSelected(Activity.java:2708)
W/System.err(19851):     at
com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1110)
W/System.err(19851):     at
com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
W/System.err(19851):     at
com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
W/System.err(19851):     at
com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
W/System.err(19851):     at
com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:645)
W/System.err(19851):     at
com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:210)
W/System.err(19851):     at android.view.View.performClick(View.java:4640)
W/System.err(19851):     at android.view.View$PerformClick.run(View.java:19421)
W/System.err(19851):     at android.os.Handler.handleCallback(Handler.java:733)
W/System.err(19851):     at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err(19851):     at android.os.Looper.loop(Looper.java:136)
W/System.err(19851):     at
android.app.ActivityThread.main(ActivityThread.java:5579)
W/System.err(19851):     at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(19851):     at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(19851):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
W/System.err(19851):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
W/System.err(19851):     at dalvik.system.NativeStart.main(Native Method)
W/System.err(19851): /mnt/sdcard/AppDoh/on-create.scm:6:10: unbound
location: current-activity
W/System.err(19851):     at gnu.expr.ReferenceExp.apply(ReferenceExp.java:158)
W/System.err(19851):     at
gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
W/System.err(19851):     at
gnu.mapping.CallContext.getFromContext(CallContext.java:264)
W/System.err(19851):     at gnu.expr.Expression.eval(Expression.java:28)
W/System.err(19851):     at gnu.expr.ApplyExp.apply(ApplyExp.java:141)
W/System.err(19851):     at
gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
W/System.err(19851):     at
gnu.mapping.CallContext.getFromContext(CallContext.java:264)
W/System.err(19851):     at gnu.expr.Expression.eval(Expression.java:28)
W/System.err(19851):     at gnu.expr.LetExp.evalVariable(LetExp.java:24)
W/System.err(19851):     at gnu.expr.LetExp.apply(LetExp.java:57)
W/System.err(19851):     at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:302)
W/System.err(19851):     at gnu.expr.ModuleExp.evalModule(ModuleExp.java:219)
W/System.err(19851):     at kawa.Shell.run(Shell.java:291)
W/System.err(19851):     at kawa.Shell.runFile(Shell.java:523)
W/System.err(19851):     at kawa.standard.load.apply2(load.java:67)
W/System.err(19851):     at kawa.standard.load.apply1(load.java:27)
W/System.err(19851):     at com.benjisimon.appdoh.main.doLoad(main.scm:60)
W/System.err(19851):     at
com.benjisimon.appdoh.main.onOptionsItemSelected(main.scm:47)
W/System.err(19851):     at
android.app.Activity.onMenuItemSelected(Activity.java:2708)
W/System.err(19851):     at
com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1110)
W/System.err(19851):     at
com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
W/System.err(19851):     at
com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
W/System.err(19851):     at
com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
W/System.err(19851):     at
com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:645)
W/System.err(19851):     at
com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:210)
W/System.err(19851):     at android.view.View.performClick(View.java:4640)
W/System.err(19851):     at android.view.View$PerformClick.run(View.java:19421)
W/System.err(19851):     at android.os.Handler.handleCallback(Handler.java:733)
W/System.err(19851):     at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err(19851):     at android.os.Looper.loop(Looper.java:136)
W/System.err(19851):     at
android.app.ActivityThread.main(ActivityThread.java:5579)
W/System.err(19851):     at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(19851):     at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(19851):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
W/System.err(19851):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
W/System.err(19851):     at dalvik.system.NativeStart.main(Native Method)
W/System.err(19851): /mnt/sdcard/AppDoh/on-create.scm:6:10: unbound
location: current-activity
W/System.err(19851):     at gnu.expr.ReferenceExp.apply(ReferenceExp.java:158)
W/System.err(19851):     at
gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
W/System.err(19851):     at
gnu.mapping.CallContext.getFromContext(CallContext.java:264)
W/System.err(19851):     at gnu.expr.Expression.eval(Expression.java:28)
W/System.err(19851):     at gnu.expr.ApplyExp.apply(ApplyExp.java:141)
W/System.err(19851):     at
gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
W/System.err(19851):     at
gnu.mapping.CallContext.getFromContext(CallContext.java:264)
W/System.err(19851):     at gnu.expr.Expression.eval(Expression.java:28)
W/System.err(19851):     at gnu.expr.LetExp.evalVariable(LetExp.java:24)
W/System.err(19851):     at gnu.expr.LetExp.apply(LetExp.java:57)
W/System.err(19851):     at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:302)
W/System.err(19851):     at gnu.expr.ModuleExp.evalModule(ModuleExp.java:219)
W/System.err(19851):     at kawa.Shell.run(Shell.java:291)
W/System.err(19851):     at kawa.Shell.runFile(Shell.java:523)
W/System.err(19851):     at kawa.standard.load.apply2(load.java:67)
W/System.err(19851):     at kawa.standard.load.apply1(load.java:27)
W/System.err(19851):     at com.benjisimon.appdoh.main.doLoad(main.scm:60)
W/System.err(19851):     at
com.benjisimon.appdoh.main.onOptionsItemSelected(main.scm:47)
W/System.err(19851):     at
android.app.Activity.onMenuItemSelected(Activity.java:2708)
W/System.err(19851):     at
com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1110)
W/System.err(19851):     at
com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
W/System.err(19851):     at
com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
W/System.err(19851):     at
com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
W/System.err(19851):     at
com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:645)
W/System.err(19851):     at
com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:210)
W/System.err(19851):     at android.view.View.performClick(View.java:4640)
W/System.err(19851):     at android.view.View$PerformClick.run(View.java:19421)
W/System.err(19851):     at android.os.Handler.handleCallback(Handler.java:733)
W/System.err(19851):     at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err(19851):     at android.os.Looper.loop(Looper.java:136)
W/System.err(19851):     at
android.app.ActivityThread.main(ActivityThread.java:5579)
W/System.err(19851):     at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(19851):     at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err(19851):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
W/System.err(19851):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
W/System.err(19851):     at dalvik.system.NativeStart.main(Native Method)
W/System.err(19851): /mnt/sdcard/AppDoh/on-create.scm:6:10: unbound
location: current-activity
W/System.err(19851):     at gnu.expr.ReferenceExp.apply(ReferenceExp.java:158)
W/System.err(19851):     at
gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
W/System.err(19851):     at
gnu.mapping.CallContext.getFromContext(CallContext.java:264)
W/System.err(19851):     at gnu.expr.Expression.eval(Expression.java:28)
W/System.err(19851):     at gnu.expr.ApplyExp.apply(ApplyExp.java:141)
W/System.err(19851):     at
gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
W/System.err(19851):     at
gnu.mapping.CallContext.getFromContext(CallContext.java:264)
W/System.err(19851):     at gnu.expr.Expression.eval(Expression.java:28)
W/System.err(19851):     at gnu.expr.LetExp.evalVariable(LetExp.java:24)
W/System.err(19851):     at gnu.expr.LetExp.apply(LetExp.java:57)
W/System.err(19851):     at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:302)
W/System.err(19851):     at gnu.expr.ModuleExp.evalModule(ModuleExp.java:219)
W/System.err(19851):     at kawa.Shell.run(Shell.java:291)
W/System.err(19851):     at kawa.Shell.runFile(Shell.java:523)
W/System.err(19851):     at kawa.standard.load.apply2(load.java:67)
W/System.err(19851):     at kawa.standard.load.apply1(load.java:27)
W/System.err(19851):     at com.benjisimon.appdoh.main.doLoad(main.scm:60)
W/System.err(19851):     at
com.benjisimon.appdoh.main.onOptionsItemSelected(main.scm:47)
W/System.err(19851):     at
android.app.Activity.onMenuItemSelected(Activity.java:2708)
W/System.err(19851):     at
com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1110)
W/System.err(19851):     at
com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
W/System.err(19851):     at
com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
W/System.err(19851):     at
com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
W/System.err(19851):     at
com.android.internal.view.menu.ActionMenuView.invokeItem(ActionMenuView.java:645)
W/System.err(19851):     at
com.android.internal.view.menu.ActionMenuItemView.onClick(ActionMenuItemView.java:210)
W/System.err(19851):     at android.view.View.performClick(View.java:4640)
W/System.err(19851):     at android.view.View$PerformClick.run(View.java:19421)
W/System.err(19851):     at android.os.Handler.handleCallback(Handler.java:733)
I/on-create.scm(19851): Ending




-- 
Have an idea for software?  I can make it happen -
http://www.ideas2executables.com
My Blog: http://www.BlogByBen.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]