Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

unbound neko.context/context causes application to crash #24

Open
ghost opened this issue Mar 12, 2014 · 4 comments
Open

unbound neko.context/context causes application to crash #24

ghost opened this issue Mar 12, 2014 · 4 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Mar 12, 2014

How to reproduce:

  • Create a standard lein-droid application, including splash screen as a MAIN category activity and a central DEFAULT activity
  • Start app and central activity; The activity needs to i.e. call neko.data/get-shared-preferences which uses the global ref to neko.context/context
  • Leave app by switching launcher
  • Start a couple of memory-hungry processes to force activity destruction
  • Launch the activity, make sure that in your test case the splash screen isn't shown again, if neccesary repeat.
  • Activity will crash as soon as neko.data/get-shared-preferences is called with a RuntimeException:

clojure.lang.Var$Unbound cannot be cast to android.content.Context

It seems that the SplashActivity's static firstLaunch field is still in its previous state, causing the splash activity to directly proceed(), without calling neko.init/init again.

I'm filing this against neko rather than lein-droid, because I'd like to propose that the use of neko.context/context should be completely removed from the library. It appears to me that the current solution is neither idiomatic for Clojure nor for Android ...

Update 2014-03-14: You may have to implement a sticky service that's restarted once the starting activity is destroyed to reproduce.

@ghost
Copy link
Author

ghost commented Mar 18, 2014

Update 2014-03-19:
For reference of a somewhat rushed removal of all static global contexts, see my fork at https://github.com/vschlecht/neko; Currently this breaks the data.readers and implies a more awkward interface to notify, the rest is rather straightforward.

@alexander-yakushev
Copy link

You are right about this being not idiomatic. Although if I could stand an additional arguments to toasts, data readers is really a miss. Do you think they can be somehow preserved with removing the static context instance?

@ghost
Copy link
Author

ghost commented Apr 1, 2014

Yes, I think the data-readers could be salvaged:
Since context is needed only to construct the resource path, which in turn depends on the package name, that's something that could be taken care of by lein-droid at compile time.

Would it be thinkable to rip the data-readers out of neko, and make them part of lein-droid?

@alexander-yakushev
Copy link

Before I apply the changes I'd like to discuss it publicly: https://groups.google.com/forum/#!topic/clojure-android/X4KDuLE6Oeg
Please join if you got new thoughts about the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant