{"action":"created","issue":{"url":"https://api.github.com/repos/moagrius/TileView/issues/205","labels_url":"https://api.github.com/repos/moagrius/TileView/issues/205/labels{/name}","comments_url":"https://api.github.com/repos/moagrius/TileView/issues/205/comments","events_url":"https://api.github.com/repos/moagrius/TileView/issues/205/events","html_url":"https://github.com/moagrius/TileView/issues/205","id":112124306,"number":205,"title":"Crashes with caching enabled","user":{"login":"dmo60","id":1223891,"avatar_url":"https://avatars.githubusercontent.com/u/1223891?v=3","gravatar_id":"","url":"https://api.github.com/users/dmo60","html_url":"https://github.com/dmo60","followers_url":"https://api.github.com/users/dmo60/followers","following_url":"https://api.github.com/users/dmo60/following{/other_user}","gists_url":"https://api.github.com/users/dmo60/gists{/gist_id}","starred_url":"https://api.github.com/users/dmo60/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmo60/subscriptions","organizations_url":"https://api.github.com/users/dmo60/orgs","repos_url":"https://api.github.com/users/dmo60/repos","events_url":"https://api.github.com/users/dmo60/events{/privacy}","received_events_url":"https://api.github.com/users/dmo60/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-19T11:16:53Z","updated_at":"2015-10-19T14:20:12Z","closed_at":null,"body":"Hello @moagrius!\r\n\r\nFirst of all, great library! It is exactly what I was looking for, so many features, thank you!\r\n\r\nI want to use disk caching for my tiles. Your latest commits made it work quite beautifully, but I still have one issue with it. I am showing floor plans for university buildings and the user is able to switch the floor level. When he does so, I create a new TileView showing tiles for the new floor and destroy the old one (which was showing the previously selected floor). More or less, it looks like this:\r\n\r\n```\r\n        // new floor selected, destroy old tileview\r\n        if (mTileView != null) {\r\n            mTileView.setVisibility(View.GONE);\r\n            mTileView.destroy();\r\n            mTileViewContainer.removeView(mTileView);\r\n        }\r\n\r\n        // add new tileview\r\n        mTileView = new TileView(getActivity());\r\n        mTileView.setTileDecoder(new BitmapDecoderHttp());\r\n        mTileView.setCacheEnabled(true);\r\n        mTileView.setTransitionsEnabled(true);\r\n        mTileView.addTileViewEventListener(this);\r\n\r\n        mTileViewContainer.addView(mTileView);\r\n\r\n        mTileView.setSize(...);\r\n        // set detail levels, etc...\r\n```\r\n\r\nHowever, when switching floors, especially when doing so quite fast, it crashes regularly with the following exception:\r\n\r\n```\r\njava.lang.IllegalStateException\r\n     at com.jakewharton.disklrucache.DiskLruCache.completeEdit(DiskLruCache.java:511)\r\n     at com.jakewharton.disklrucache.DiskLruCache.access$2200(DiskLruCache.java:88)\r\n     at com.jakewharton.disklrucache.DiskLruCache$Editor.abort(DiskLruCache.java:824)\r\n     at com.qozix.tileview.tiles.TileCache.addBitmapToDiskCache(TileCache.java:158)\r\n     at com.qozix.tileview.tiles.TileCache.addBitmap(TileCache.java:73)\r\n     at com.qozix.tileview.tiles.Tile.decode(Tile.java:74)\r\n     at com.qozix.tileview.tiles.TileManager.decodeIndividualTile(TileManager.java:302)\r\n     at com.qozix.tileview.tiles.TileDownloadRunner.run(TileDownloadRunner.java:22)\r\n     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)\r\n     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)\r\n     at java.lang.Thread.run(Thread.java:818)\r\n```\r\n\r\nI am using DiskLruCache v2.0.2.\r\n\r\nI've looked at `TileCache.java:158`. I don't know if it is a legit fix, but you could try catching the `IllegalStateException` in addition to the `IOException`. But to be honest, I did not dig that deep to truely understand what's going on here. I suspect it's kind of a timing issue.\r\n\r\nWhat do you think?"},"comment":{"url":"https://api.github.com/repos/moagrius/TileView/issues/comments/149226938","html_url":"https://github.com/moagrius/TileView/issues/205#issuecomment-149226938","issue_url":"https://api.github.com/repos/moagrius/TileView/issues/205","id":149226938,"user":{"login":"dmo60","id":1223891,"avatar_url":"https://avatars.githubusercontent.com/u/1223891?v=3","gravatar_id":"","url":"https://api.github.com/users/dmo60","html_url":"https://github.com/dmo60","followers_url":"https://api.github.com/users/dmo60/followers","following_url":"https://api.github.com/users/dmo60/following{/other_user}","gists_url":"https://api.github.com/users/dmo60/gists{/gist_id}","starred_url":"https://api.github.com/users/dmo60/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmo60/subscriptions","organizations_url":"https://api.github.com/users/dmo60/orgs","repos_url":"https://api.github.com/users/dmo60/repos","events_url":"https://api.github.com/users/dmo60/events{/privacy}","received_events_url":"https://api.github.com/users/dmo60/received_events","type":"User","site_admin":false},"created_at":"2015-10-19T14:20:12Z","updated_at":"2015-10-19T14:20:12Z","body":"Thanks for the quick response! Catching everything should probably work. Looking forward to version 2.0 :+1: "}}