Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when caching is enabled #140

Closed
ghost opened this issue Sep 10, 2014 · 6 comments
Closed

Crash when caching is enabled #140

ghost opened this issue Sep 10, 2014 · 6 comments

Comments

@ghost
Copy link

ghost commented Sep 10, 2014

I get random crashes when using setCacheEnabled(true).

    dependencies {
      compile 'com.jakewharton:disklrucache:1.3.1'
      compile 'com.qozix:TileView:1.0.11'
    }
    mTileView.addDetailLevel(1.000f, "tiles/1000/%col%_%row%.png", "samples/200.png");
    mTileView.addDetailLevel(0.500f, "tiles/500/%col%_%row%.png", "samples/200.png");
    mTileView.addDetailLevel(0.250f, "tiles/250/%col%_%row%.png", "samples/100.png");
    mTileView.addDetailLevel(0.125f, "tiles/125/%col%_%row%.png", "samples/100.png");
    mTileView.setCacheEnabled(true); //TODO disabled, currently causes random crashes
    mTileView.setTransitionsEnabled(false);

NullPointerException:

23540-24079/ E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-124450
    Process: com.test.tiles PID: 23540
    java.lang.NullPointerException
            at com.qozix.tileview.tiles.TileCache$4.run(TileCache.java:106)
            at java.lang.Thread.run(Thread.java:841)

Anybody else experiencing this?

@ghost
Copy link
Author

ghost commented Sep 10, 2014

Also have WRITE_EXTERNAL_STORAGE permission in manifest.

@ghost
Copy link
Author

ghost commented Sep 10, 2014

Could it be because of the old disklrucache library version?

@moagrius
Copy link
Owner

Sorry for the delay - I didn't notice this thread until reviewing old issues just now.

Actually, the new version of DiskLruCache isn't compatible - this one should work: https://oss.sonatype.org/content/repositories/releases/com/jakewharton/disklrucache/1.3.1/disklrucache-1.3.1.jar

Post back if that doesn't fix it.

@ghost
Copy link
Author

ghost commented Sep 22, 2014

No worries, I am actually using that version. (compile 'com.jakewharton:disklrucache:1.3.1')

@moagrius
Copy link
Owner

Ah, yep, you mentioned the version right up front. So my next best guess would be here: https://github.com/moagrius/TileView/blob/master/src/com/qozix/tileview/tiles/TileCache.java#L61 Maybe the File pointer is null. Try adding a null test before the try/catch in the source. If that works you can do a fork and PR and I'll merge, otherwise I'll do it when I get some time.

Thanks for posting.

@moagrius
Copy link
Owner

This is corrected in the latest commit (really just needed be less strict on what exceptions were caught). Not sure why this started showing up out of the blue, but I see it as well. Note that I have not released a new .jar, you'll need to grab the source, nor have I updated the docs (just moved to AS from Eclipse, which had those tasks pretty well baked-in, still getting used to AS).

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

No branches or pull requests

1 participant