lftjcq / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

osmdroid-android-3.0.6.jar, tile loading slow or fails #289

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1.  I've just replaced a working project's 3.0.5 jar with the new 3.0.6 
version. I've made no code changes in my app other than the version number. 
I've built the project using the latest SDK tools (r16) and Ant on a Windows 64 
bit machine. I've downloaded a release version on to a Galaxy S2 running  
Android 2.3.5 
2.
3.

What is the expected output? What do you see instead?

I expected the smooth loading of tiles as with previous versions of the jar. As 
I zoom and pan the map, the tile loading is very 'blocky' and slow compared to 
the 3.0.5 build. Sometimes the tiles do not appear at all. I rebuilt the app 
with 3.0.5 and tested again - it's fine.

What version of the product are you using? On what operating system?

osmdroid-android-3.0.6.jar, real phone running 2.3.5 Android, Wifi connection 
through ADSL router

Please provide any additional information below.

I'll try and build a minimal code example to test on an emulator when I get a 
chance

Original issue reported on code.google.com by n...@nthearle.demon.co.uk on 1 Jan 2012 at 10:11

GoogleCodeExporter commented 8 years ago
 I ran this minimal app code (android 2.1 compatible)

import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;

import android.app.Activity;
import android.os.Bundle;

// This is all you need to display an OSM map using osmdroid
public class OsmdroidDemoMap extends Activity {

    private MapView         mMapView;
    private MapController   mMapController;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.osm_main);
        mMapView = (MapView) findViewById(R.id.mapview);
        mMapView.setTileSource(TileSourceFactory.MAPNIK);
        mMapView.setBuiltInZoomControls(true);
        mMapController = mMapView.getController();
        mMapController.setZoom(13);
        GeoPoint gPt = new GeoPoint(51500000, -150000);
        //Centre map near to Hyde Park Corner, London
        mMapController.setCenter(gPt);
    }
}
/* HAVE THIS AS YOUR osm_main.xml
---------------------------------------------------------- XML START
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <org.osmdroid.views.MapView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:id="@+id/mapview"
        ></org.osmdroid.views.MapView>
</LinearLayout>
---------------------------------------------------------- XML END

It was much the same on the emulator (perhaps a few less missing tiles) The 
missing tiles never appeared (see attached screen dump)

Original comment by n...@nthearle.demon.co.uk on 1 Jan 2012 at 10:28

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have the same problem. I found that on the Samsung Galaxy Nexus with Android 
4.0.1 several tiles do not load at all. Loading tiles seems a bit slower than 
3.0.5. I did not find any solution yet.

Original comment by patrick-...@webs.nl on 2 Jan 2012 at 1:49

GoogleCodeExporter commented 8 years ago
It's also easy to test by just comparing the two apk's:
http://osmdroid.googlecode.com/files/OpenStreetMapViewer-3.0.6.apk
http://osmdroid.googlecode.com/files/OpenStreetMapViewer-3.0.5.apk

I don't know about the "blocky" loading, but it does appear to never load tiles 
sometimes. I haven't had a chance to look at the code yet, but I guess it's 
when a download fails and somehow the pending cache gets stuck thinking it's 
still in progress.

Original comment by neilboyd on 2 Jan 2012 at 2:46

GoogleCodeExporter commented 8 years ago
Do you think you could make a fix for this issue? thanks.

Original comment by patrick-...@webs.nl on 3 Jan 2012 at 12:28

GoogleCodeExporter commented 8 years ago
this problem is persisting even in offline mode . 

Original comment by pra...@wcities.com on 4 Jan 2012 at 7:11

GoogleCodeExporter commented 8 years ago
I think the fix for issue 207 helps this, although that doesn't make sense if 
the issue is also happening in offline mode.

Original comment by neilboyd on 4 Jan 2012 at 10:09

GoogleCodeExporter commented 8 years ago
The fix for issue 207 did not alleviate this. This was the strange new issue I 
was talking about in that issue. It happened when I updated to latest version 
and applied the patch you posted there, so unless other things have been 
changed it still persists.

Original comment by DuneL...@gmail.com on 5 Jan 2012 at 10:35

GoogleCodeExporter commented 8 years ago
This issue makes 3.0.6 unusable in my opinion. You should revert to 3.0.5 being 
the downloadable jar till it is sorted anyone trying to start off with osmdroid 
now is liable to stop in a hurry.

Original comment by iforpow...@gmail.com on 12 Jan 2012 at 10:18

GoogleCodeExporter commented 8 years ago
Yeah, I agree. And that would be too bad, because things were working fine 
before.

Original comment by DuneL...@gmail.com on 12 Jan 2012 at 10:33

GoogleCodeExporter commented 8 years ago
Looking at the commits from 3.0.5 to 3.0.6 the work putting in the background 
scaling for issue 46 is probobly the cause.  I will try and get to know the 
code some more in that area, just to see if I can switch it off for a start.

Original comment by iforpow...@gmail.com on 12 Jan 2012 at 10:58

GoogleCodeExporter commented 8 years ago
Did any one try r1010 on 3.0.5 ?? 

Original comment by pra...@wcities.com on 13 Jan 2012 at 6:18

GoogleCodeExporter commented 8 years ago
I just tried reming out line 338 in mapView.java

mTileProvider.rescaleCache(newZoomLevel, curZoomLevel, getScreenRect(null));

This looks to workaround the problem.  I am not farmiliar enough with the code 
to know if there is anything else needed but it looks OK in my App given a 
quick test.

An option to enable / disable this cache rescaling and a default to off would 
probobly be the right short term workaround antil the code is cleaned up 
properly.

Original comment by iforpow...@gmail.com on 13 Jan 2012 at 9:46

GoogleCodeExporter commented 8 years ago
If you think there's a problem with the fix for issue 46 then you could disable 
it, but of course then issue 46 is still an issue. It would be better if you 
could identify an issue with the scaling and fix it.

Original comment by neilboyd on 16 Jan 2012 at 6:04

GoogleCodeExporter commented 8 years ago
I think I found the problem. The scaled bitmaps aren't being replaced by real 
unscaled tiles.

In ScaleTileLooper, finaliseLoop() the scaled map tile added to the cache is 
not marked as expired.

ExpirableBitmapDrawable expiredBitmap = new ExpirableBitmapDrawable(bitmap);
expiredBitmap.setState(new int[]{-1}); // expired
mTileCache.putTile(tile, expiredBitmap);

On a separate note is there some clever programming reason why is state an int 
array? 

Original comment by t...@chellew.co.uk on 1 Feb 2012 at 1:00

GoogleCodeExporter commented 8 years ago
That makes good sense. When I wrote ExpirableBitmapDrawable it was originally 
called ExpiredBitmapDrawable and it was always expired, but then I changed it 
to be not expired by default. Seems I forgot to change this.

state is an int array in Bitmap.getState
http://developer.android.com/reference/android/graphics/drawable/Drawable.html#g
etState()

Original comment by neilboyd on 1 Feb 2012 at 2:06

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r1073.

Original comment by neilboyd on 1 Feb 2012 at 2:12

GoogleCodeExporter commented 8 years ago
That's good news - thank you. I'm still using the 3.0.5 jar but with the change 
of URL the cycle map doesn't work. I guess that I'll have to wait for 3.0.8 to 
have a jar which fixes 289 and the cycle map URL issues?

Original comment by n...@nthearle.demon.co.uk on 1 Feb 2012 at 2:34

GoogleCodeExporter commented 8 years ago
Still having this issue and I'm using the 3.0.8 jar.  It will stop loading 
tiles completely.  I have tested on a motorola droid(gingerbread) and galaxy 
tab 10.1(honeycomb).  Not sure what the issue is, but if I use the osmDroid app 
from the market it works fine...Tried earlier jars and same issue.

Original comment by patjacks...@gmail.com on 21 Aug 2012 at 7:33

GoogleCodeExporter commented 8 years ago
I also have the problem with 3.0.8 and 3.0.9-20120628.050326-1: no tiles shown 
at all, just the background grid, even though the app keeps downloading data 
(tiles I suppose) from the internet forever.  I'm relieved I found that bug 
report; I was starting to think I'm crazy/stupid.  Using 3.0.5, I now have a 
functional map.  I'm new to all this but my little investigation led me to 
think the view port was somehow incorrectly set and tiles were downloaded 
outside (even very far) from the requested bounding box.  Just an hypothesis 
from a newcomer so please don't pay too much attention to it.  Let me know if I 
can help in some way.

Original comment by tity...@gmail.com on 18 Oct 2012 at 12:26

GoogleCodeExporter commented 8 years ago
Hello, I have also the same problem with 3.0.8 - tiles are randomly not 
displayed as shown on 'Osmdroid306Dump.jpg'. Application is running offline 
with local tile cache, don't know, if it is important. Same map scale and 
position renders well when new map component is created. 
Version 3.0.5 works well, but 3.0.8 performs smoothly and therefore it is 
preferred for me. Is there any chance this problem to be fixed?

Original comment by tomas.r...@gmail.com on 24 Mar 2013 at 7:24

GoogleCodeExporter commented 8 years ago
Same problem here with 3.0.10 - when zooming or scrolling using an offline 
sqlite db some random tiles are not displayed. I can also confirm 3.0.5 does 
not have this problem.

Original comment by vit.hrad...@gmail.com on 15 Jul 2013 at 9:57

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I have the same issue with 3.0.8 and 3.0.10 also. It happens only in offline 
mode.
resourceProxy = new DefaultResourceProxyImpl(getApplicationContext());
        setContentView(R.layout.activity_map_view);
        myMapView.setTileSource(new XYTileSource("OSMmaptracker",
                ResourceProxy.string.offline_mode, 10, 18, 256, ".png",
                "http://tile.openstreetmap.org/"));
        myMapView.setBuiltInZoomControls(true);     
        myMapView.setClickable(true);
        myMapView.setMultiTouchControls(true);
        myMapView.setUseDataConnection(false);
        myMapView.setMapViewActivity(this);
        myMapView.setScrollableAreaLimit(new BoundingBoxE6(49.4400781318,
                20.4353853749, 49.4005902108, 20.3925485542));
Has anybody find a solution?

Original comment by sys...@gmail.com on 1 Sep 2013 at 5:21

GoogleCodeExporter commented 8 years ago
Seeing the same problem on Samsung Replenish (model SPH-M580 with Android 
version 2.3.6) using library version 3.0.10. Problem occurs in both my APK and 
with the sample APK provided 
(https://code.google.com/p/osmdroid/downloads/list).

Original comment by cola...@gmail.com on 6 Sep 2013 at 9:37

GoogleCodeExporter commented 8 years ago
People are still having this issue, so I am going to re-open this. If you have 
a small offline SQL database that exhibits this then please post it here so we 
can reproduce this issue.

Original comment by kurtzm...@gmail.com on 23 Sep 2013 at 2:15

GoogleCodeExporter commented 8 years ago

Original comment by kurtzm...@gmail.com on 23 Sep 2013 at 2:16

GoogleCodeExporter commented 8 years ago
FYI - the changes between 3.0.5 (the last working version?) and 3.0.6 (the 
first broken version?) span approximately r974 to r1033. So what broke in that 
span?

Original comment by kurtzm...@gmail.com on 23 Sep 2013 at 2:21

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Same problem with 4.0.  I sometimes find if a tile has been drawn correctly, 
then I pan it off-screen and back, it is no longer drawn (either plane grey or 
a grey grid).

Original comment by yagibl...@googlemail.com on 25 Oct 2013 at 1:27

GoogleCodeExporter commented 8 years ago
Would patch of issue 332 (which seems to be a duplicate of this issue) help?

Original comment by notdiffi...@gmx.net on 23 Nov 2013 at 2:13

GoogleCodeExporter commented 8 years ago

Original comment by neilboyd on 25 Jan 2014 at 6:14

GoogleCodeExporter commented 8 years ago
I have the same problem (Version 4.1). Is there any fix?

Original comment by tron.cos...@gmail.com on 4 Feb 2014 at 5:23

GoogleCodeExporter commented 8 years ago
Here finally a patch: 
http://www.file-upload.net/download-8633927/fixTileLoadFailure.patch.html

changes:
- fix problem tiles not loading in offline mode (fixes 
https://code.google.com/p/osmdroid/issues/detail?id=289 by increasing cache 
size dynamically)
- added warning if network permissions not granted
- use 0.75 as load factor for LRUMapTileCache

@devs: this is just a small fix but it finally makes osmdroid usable. please 
verify and include asap. thanks.

Original comment by notdiffi...@gmx.net on 18 Feb 2014 at 3:33

GoogleCodeExporter commented 8 years ago
I do not trust file-upload: http://textuploader.com/1hhl

Original comment by notdiffi...@gmx.net on 18 Feb 2014 at 3:36

GoogleCodeExporter commented 8 years ago
As long my fix is not included. Increasing the cache size should help:

    mMapView.getOverlayManager().getTilesOverlay().setOvershootTileCache(300);

Original comment by notdiffi...@gmx.net on 19 Feb 2014 at 10:23

GoogleCodeExporter commented 8 years ago
Thanks for creating this patch. I'm having troubles including it in my Project. 
Would you be so kind to create a jar file that includes this patch?

Thanks alot

Original comment by tok...@googlemail.com on 4 Mar 2014 at 5:23

GoogleCodeExporter commented 8 years ago
I tried to incorporate the patch from #34 into my copy of the library. 
Unfortunately I started getting LowMemory exceptions, caused by this line in 
MapTileProviderBase.ScaleTileLooper.finaliseLoop(): 

mTileCache.ensureCapacity(mTileCache.getCapacity() + mNewTiles.size());

The above keeps increasing mTileCache capacity indefinitely, and at some point 
we run out of memory. I admit though, that as long as there is enough memory, 
missing tiles do not appear. 
It seems to me that missing tiles appear when the loading of actual tiles from 
disk is a bit slow. If it's fast enough, all is well. I'll try to investigate a 
little further.

Original comment by daniel.k...@gmail.com on 10 May 2014 at 10:52

GoogleCodeExporter commented 8 years ago
Sir,
i have inculcated your OsmdroidDemoMap in eclipse and trying to get offline map.
but iam getting error after including the libraries which you have suggested 
the error was as follows:" Could not find class org.osmdroid.util.geopoint, 
referenced from method with the package name".
Please suggest me how to get rid off those errors and displays a map.
Thanks 
Regards

Original comment by prithams...@gmail.com on 4 Jul 2014 at 8:28

GoogleCodeExporter commented 8 years ago
Any progress on this? Happens with offline maps on osmdroid 4.0 and the latest 
(at time of this post) 4.2 built from source code. Tested on HTC Wildfire 
(Android 2.2), and I was even able to reproduce it on Genymotion emulator, 
though it happens there rarely comparing to HTC Wildfire (probably because 
Genymotion loads offline tiles faster, or has more memory - I do not know).

Original comment by gmi...@gmail.com on 23 Oct 2014 at 3:59

GoogleCodeExporter commented 8 years ago
Patch http://www.file-upload.net/download-8633927/fixTileLoadFailure.patch.html 
doesn't work for me, I still get the same issue (missing tiles after zoom 
in/out). osmdroid 4.2

Original comment by gmi...@gmail.com on 23 Oct 2014 at 5:49

GoogleCodeExporter commented 8 years ago
The same thing with 4.3. If I remove tile folder and download it again, 
everything will be fine. What do?

Original comment by dolgopol...@gmail.com on 27 Jul 2015 at 8:32