osmandapp / OsmAnd

OsmAnd
https://osmand.net
Other
4.62k stars 1.01k forks source link

Osmand triggering half open file limit #6406

Open cor-mt opened 5 years ago

cor-mt commented 5 years ago

I'm using the latest version of Osmand from f-droid, it was working file till I moved all the files over to the sd card, now it fails with the following for each file after a certain point.

E net.osmand: ResourceManager Fail to initialize file.obf
E net.osmand: java.io.FileNotFoundException: /path/file.obf: open failed: EMFILE (Too many open files)
E net.osmand:   at libcore.io.IoBridge.open(IoBridge.java:455)
E net.osmand:   at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
E net.osmand:   at net.osmand.plus.resources.ResourceManager$BinaryMapReaderResource.getReader(ResourceManager.java:131)
E net.osmand:   at net.osmand.plus.resources.ResourceManager.getQuickSearchFiles(ResourceManager.java:1007)
E net.osmand:   at net.osmand.plus.search.QuickSearchHelper.setRepositoriesForSearchUICore(QuickSearchHelper.java:121)
E net.osmand:   at net.osmand.plus.search.QuickSearchHelper.initSearchUICore(QuickSearchHelper.java:90)
E net.osmand:   at net.osmand.plus.AppInitializer.startApplicationBackground(AppInitializer.java:659)
E net.osmand:   at net.osmand.plus.AppInitializer.access$300(AppInitializer.java:84)
E net.osmand:   at net.osmand.plus.AppInitializer$9.run(AppInitializer.java:893)
E net.osmand:   at java.lang.Thread.run(Thread.java:761)
E net.osmand: Caused by: android.system.ErrnoException: open failed: EMFILE (Too many open files)
E net.osmand:   at libcore.io.Posix.open(Native Method)
E net.osmand:   at libcore.io.BlockGuardOs.open(BlockGuardOs.java:187)
E net.osmand:   at libcore.io.IoBridge.open(IoBridge.java:441)
E net.osmand:   ... 9 more

According to stackoverflow this could be caused by having a lower half open file limit on the sd card than internal.

The following, Osmand not listening to the file open error and running queries on the failed to open db?

W System.err: java.lang.NullPointerException: Attempt to invoke interface method 'int net.osmand.plus.api.SQLiteAPI$SQLiteConnection.getVersion()' on a null object reference
W System.err:   at net.osmand.plus.poi.PoiFiltersHelper$PoiFilterDbHelper.openConnection(PoiFiltersHelper.java:449)
W System.err:   at net.osmand.plus.poi.PoiFiltersHelper$PoiFilterDbHelper.getReadableDatabase(PoiFiltersHelper.java:444)
W System.err:   at net.osmand.plus.poi.PoiFiltersHelper.getUserDefinedPoiFilters(PoiFiltersHelper.java:201)
W System.err:   at net.osmand.plus.search.QuickSearchHelper.refreshCustomPoiFilters(QuickSearchHelper.java:110)
W System.err:   at net.osmand.plus.search.QuickSearchHelper.initSearchUICore(QuickSearchHelper.java:104)
W System.err:   at net.osmand.plus.AppInitializer.startApplicationBackground(AppInitializer.java:659)
W System.err:   at net.osmand.plus.AppInitializer.access$300(AppInitializer.java:84)
W System.err:   at net.osmand.plus.AppInitializer$9.run(AppInitializer.java:893)
W System.err:   at java.lang.Thread.run(Thread.java:761)

The above is not directly causing the app to crash but it fails later by not being able to load "libRSDriver.so" because of the previous triggered limit.

Would it be possible to close all the files with no info for the current location + zoom level as soon as possible and act proactive like dropping overlay tiles if running into file limit errors?

rponline commented 3 years ago

I use the fdroid version combined with SD card too. Just found your issue while researching on my crash-problem.

My error int net.osmand.plus.api.SQLiteAPI$SQLiteConnection.getVersion()' on a null object reference is the similar but gets thrown on another place than yours i guess. (I'm not a java dev :))

The app crashes always after searching for sth or when i define a route for navigation.

This exception gets already thrown when i start searching. In the next step when i hit the search button, the app crashes.

Version OsmAnd~ 3.9.10
17.06.2021 9:58:31
Apk Version : 3.9.10 400
Exception occured in thread Thread[main,5,main] :
java.lang.NullPointerException: Attempt to invoke interface method 'int net.osmand.plus.api.SQLiteAPI$SQLiteConnection.getVersion()' on a null object reference
at net.osmand.plus.helpers.SearchHistoryHelper$HistoryItemDBHelper.openConnection(SearchHistoryHelper.java:348)
at net.osmand.plus.helpers.SearchHistoryHelper$HistoryItemDBHelper.getEntries(SearchHistoryHelper.java:446)
at net.osmand.plus.helpers.SearchHistoryHelper.checkLoadedEntries(SearchHistoryHelper.java:115)
at net.osmand.plus.helpers.SearchHistoryHelper.getHistoryEntries(SearchHistoryHelper.java:58)
at net.osmand.plus.settings.backend.backup.SettingsHelper.getMyPlacesItems(SettingsHelper.java:625)
at net.osmand.plus.settings.backend.backup.SettingsHelper.getSettingsByCategory(SettingsHelper.java:520)
at net.osmand.plus.settings.fragments.ExportSettingsFragment.onCreate(ExportSettingsFragment.java:81)
at androidx.fragment.app.Fragment.performCreate(Fragment.java:2586)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:838)
at androidx.fragment.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1197)
at androidx.fragment.app.FragmentTransition.calculateFragments(FragmentTransition.java:1080)
at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:119)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1866)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)

Screenshot_20210617-103341_OsmAnd~

Update: A reboot of my phone did the trick!