Not downloading #50

Closed
opened 2021-07-30 12:05:59 +00:00 by yant0 · 17 comments
yant0 commented 2021-07-30 12:05:59 +00:00 (Migrated from github.com)

Did not download

Tested on :

  • mangaread
  • ninemanga english

Tested with :

  • Samsung Galaxy Core II, android 7.1 Lineage os unofficial
  • Asus zenfone max pro m1, android 9 stock

Tried :
Changing dns
Wifi / data
Changing save location
Downloading only one chapter
Granted storage permission

Video :
https://1.filedit.ch/1/qaGWgOQOYGjmzcdQQam.mp4

Did not download Tested on : - mangaread - ninemanga english Tested with : - Samsung Galaxy Core II, android 7.1 Lineage os unofficial - Asus zenfone max pro m1, android 9 stock Tried : Changing dns Wifi / data Changing save location Downloading only one chapter Granted storage permission Video : https://1.filedit.ch/1/qaGWgOQOYGjmzcdQQam.mp4
Koitharu commented 2021-08-18 05:12:34 +00:00 (Migrated from github.com)

I cannot reproduce this issue(

I cannot reproduce this issue(
ztimms73 commented 2021-08-18 08:55:06 +00:00 (Migrated from github.com)

I can reproduce this on Nexus 5 Emulator with Android 5.1. There is exactly the same problem as he has. I can also show the logs that I caught during testing.

java.io.FileNotFoundException (an exception appeared when trying to download chapter) W/System.err: java.io.FileNotFoundException: /storage/sdcard/Android/data/org.koitharu.kotatsu.debug/cache/pages/journal.bin: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:456) at java.io.FileInputStream.(FileInputStream.java:76) at com.tomclaw.cache.Journal.readJournal(Journal.java:133) at com.tomclaw.cache.DiskLruCache.create(DiskLruCache.java:36) at com.tomclaw.cache.DiskLruCache.create(DiskLruCache.java:31) at org.koitharu.kotatsu.local.data.PagesCache.(PagesCache.kt:16) W/System.err: at org.koitharu.kotatsu.reader.ReaderModuleKt$readerModule$1$2.invoke(ReaderModule.kt:13) at org.koitharu.kotatsu.reader.ReaderModuleKt$readerModule$1$2.invoke(ReaderModule.kt:13) at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:53) at org.koin.core.instance.SingleInstanceFactory.create(SingleInstanceFactory.kt:46) at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:53) at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:51) at org.koin.mp.KoinPlatformTools.synchronized(PlatformToolsJVM.kt:20) at org.koin.core.instance.SingleInstanceFactory.get(SingleInstanceFactory.kt:51) at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(InstanceRegistry.kt:103) W/System.err: at org.koin.core.scope.Scope.resolveValue(Scope.kt:223) at org.koin.core.scope.Scope.resolveInstance(Scope.kt:211) at org.koin.core.scope.Scope.get(Scope.kt:193) at org.koitharu.kotatsu.download.ui.service.DownloadService.onCreate(DownloadService.kt:207) at android.app.ActivityThread.handleCreateService(ActivityThread.java:2761) at android.app.ActivityThread.access$1800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory) at libcore.io.Posix.open(Native Method) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186) at libcore.io.IoBridge.open(IoBridge.java:442) ... 28 more
StrictMode (an error appeared when launching the application with this allegedly downloaded manga) E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. java.lang.Throwable: Explicit termination method 'close' not called at dalvik.system.CloseGuard.open(CloseGuard.java:184) at java.util.zip.ZipFile.(ZipFile.java:173) at java.util.zip.ZipFile.(ZipFile.java:130) at org.koitharu.kotatsu.local.data.CbzFetcher.fetch(CbzFetcher.kt:25) at org.koitharu.kotatsu.local.data.CbzFetcher.fetch(CbzFetcher.kt:16) at coil.intercept.EngineInterceptor$intercept$2.invokeSuspend(EngineInterceptor.kt:405) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

I hope this will help in solving the problem.

I can reproduce this on Nexus 5 Emulator with Android 5.1. There is exactly the same problem as he has. I can also show the logs that I caught during testing. <details><summary>java.io.FileNotFoundException (an exception appeared when trying to download chapter)</summary> W/System.err: java.io.FileNotFoundException: /storage/sdcard/Android/data/org.koitharu.kotatsu.debug/cache/pages/journal.bin: open failed: ENOENT (No such file or directory) at libcore.io.IoBridge.open(IoBridge.java:456) at java.io.FileInputStream.<init>(FileInputStream.java:76) at com.tomclaw.cache.Journal.readJournal(Journal.java:133) at com.tomclaw.cache.DiskLruCache.create(DiskLruCache.java:36) at com.tomclaw.cache.DiskLruCache.create(DiskLruCache.java:31) at org.koitharu.kotatsu.local.data.PagesCache.<init>(PagesCache.kt:16) W/System.err: at org.koitharu.kotatsu.reader.ReaderModuleKt$readerModule$1$2.invoke(ReaderModule.kt:13) at org.koitharu.kotatsu.reader.ReaderModuleKt$readerModule$1$2.invoke(ReaderModule.kt:13) at org.koin.core.instance.InstanceFactory.create(InstanceFactory.kt:53) at org.koin.core.instance.SingleInstanceFactory.create(SingleInstanceFactory.kt:46) at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:53) at org.koin.core.instance.SingleInstanceFactory$get$1.invoke(SingleInstanceFactory.kt:51) at org.koin.mp.KoinPlatformTools.synchronized(PlatformToolsJVM.kt:20) at org.koin.core.instance.SingleInstanceFactory.get(SingleInstanceFactory.kt:51) at org.koin.core.registry.InstanceRegistry.resolveInstance$koin_core(InstanceRegistry.kt:103) W/System.err: at org.koin.core.scope.Scope.resolveValue(Scope.kt:223) at org.koin.core.scope.Scope.resolveInstance(Scope.kt:211) at org.koin.core.scope.Scope.get(Scope.kt:193) at org.koitharu.kotatsu.download.ui.service.DownloadService.onCreate(DownloadService.kt:207) at android.app.ActivityThread.handleCreateService(ActivityThread.java:2761) at android.app.ActivityThread.access$1800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1386) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory) at libcore.io.Posix.open(Native Method) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186) at libcore.io.IoBridge.open(IoBridge.java:442) ... 28 more </details> <details><summary>StrictMode (an error appeared when launching the application with this allegedly downloaded manga)</summary> E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. java.lang.Throwable: Explicit termination method 'close' not called at dalvik.system.CloseGuard.open(CloseGuard.java:184) at java.util.zip.ZipFile.<init>(ZipFile.java:173) at java.util.zip.ZipFile.<init>(ZipFile.java:130) at org.koitharu.kotatsu.local.data.CbzFetcher.fetch(CbzFetcher.kt:25) at org.koitharu.kotatsu.local.data.CbzFetcher.fetch(CbzFetcher.kt:16) at coil.intercept.EngineInterceptor$intercept$2.invokeSuspend(EngineInterceptor.kt:405) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665) </details> I hope this will help in solving the problem.
Koitharu commented 2021-08-19 04:17:05 +00:00 (Migrated from github.com)

Looks like DiskLruCache is buggy...

Looks like `DiskLruCache` is buggy...
Koitharu commented 2022-01-14 06:52:57 +00:00 (Migrated from github.com)

@ztimms73 I have a theory that this may be caused by lack of free disk space. Unfortunately, I can't run the emulator on my laptop due to low performance so cannot reproduce this issue. Can you check it?

@ztimms73 I have a theory that this may be caused by lack of free disk space. Unfortunately, I can't run the emulator on my laptop due to low performance so cannot reproduce this issue. Can you check it?
Koitharu commented 2022-01-14 06:54:44 +00:00 (Migrated from github.com)
And you can also try this patch
Index: app/build.gradle
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/app/build.gradle b/app/build.gradle
--- a/app/build.gradle	(revision b5fa2bd6608c246ccf4686bed92d19c4d733d7e6)
+++ b/app/build.gradle	(date 1642141182035)
@@ -100,7 +100,7 @@
 	implementation 'io.insert-koin:koin-android:3.1.4'
 	implementation 'io.coil-kt:coil-base:1.4.0'
 	implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
-	implementation 'com.github.solkin:disk-lru-cache:1.3'
+	implementation 'com.github.solkin:disk-lru-cache:1.4'
 
 	debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
 
Index: app/src/main/java/org/koitharu/kotatsu/local/data/PagesCache.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/app/src/main/java/org/koitharu/kotatsu/local/data/PagesCache.kt b/app/src/main/java/org/koitharu/kotatsu/local/data/PagesCache.kt
--- a/app/src/main/java/org/koitharu/kotatsu/local/data/PagesCache.kt	(revision b5fa2bd6608c246ccf4686bed92d19c4d733d7e6)
+++ b/app/src/main/java/org/koitharu/kotatsu/local/data/PagesCache.kt	(date 1642142338802)
@@ -1,6 +1,7 @@
 package org.koitharu.kotatsu.local.data
 
 import android.content.Context
+import android.os.StatFs
 import com.tomclaw.cache.DiskLruCache
 import org.koitharu.kotatsu.utils.FileSizeUtils
 import org.koitharu.kotatsu.utils.ext.longHashCode
@@ -13,10 +14,7 @@
 class PagesCache(context: Context) {
 
 	private val cacheDir = context.externalCacheDir ?: context.cacheDir
-	private val lruCache = DiskLruCache.create(
-		cacheDir.subdir(Cache.PAGES.dir),
-		FileSizeUtils.mbToBytes(200)
-	)
+	private val lruCache = createDiskCache()
 
 	operator fun get(url: String): File? {
 		return lruCache.get(url)?.takeIfReadable()
@@ -40,4 +38,19 @@
 		file.delete()
 		return res
 	}
+
+	private fun createDiskCache(): DiskLruCache {
+		return DiskLruCache.create(
+			cacheDir.subdir(Cache.PAGES.dir),
+			getMaxCacheSize(maxSize = FileSizeUtils.mbToBytes(20), maxPercent = 70),
+		)
+	}
+
+	private fun getMaxCacheSize(maxSize: Long, maxPercent: Int): Long {
+		return runCatching {
+			val statFs = StatFs(cacheDir.absolutePath)
+			val size = maxPercent * statFs.blockCountLong * statFs.blockSizeLong
+			return minOf(size, maxSize)
+		}.getOrDefault(maxSize)
+	}
 }
\ No newline at end of file
<details> <summary>And you can also try this patch</summary> ``` Index: app/build.gradle IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/app/build.gradle b/app/build.gradle --- a/app/build.gradle (revision b5fa2bd6608c246ccf4686bed92d19c4d733d7e6) +++ b/app/build.gradle (date 1642141182035) @@ -100,7 +100,7 @@ implementation 'io.insert-koin:koin-android:3.1.4' implementation 'io.coil-kt:coil-base:1.4.0' implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0' - implementation 'com.github.solkin:disk-lru-cache:1.3' + implementation 'com.github.solkin:disk-lru-cache:1.4' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7' Index: app/src/main/java/org/koitharu/kotatsu/local/data/PagesCache.kt IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/app/src/main/java/org/koitharu/kotatsu/local/data/PagesCache.kt b/app/src/main/java/org/koitharu/kotatsu/local/data/PagesCache.kt --- a/app/src/main/java/org/koitharu/kotatsu/local/data/PagesCache.kt (revision b5fa2bd6608c246ccf4686bed92d19c4d733d7e6) +++ b/app/src/main/java/org/koitharu/kotatsu/local/data/PagesCache.kt (date 1642142338802) @@ -1,6 +1,7 @@ package org.koitharu.kotatsu.local.data import android.content.Context +import android.os.StatFs import com.tomclaw.cache.DiskLruCache import org.koitharu.kotatsu.utils.FileSizeUtils import org.koitharu.kotatsu.utils.ext.longHashCode @@ -13,10 +14,7 @@ class PagesCache(context: Context) { private val cacheDir = context.externalCacheDir ?: context.cacheDir - private val lruCache = DiskLruCache.create( - cacheDir.subdir(Cache.PAGES.dir), - FileSizeUtils.mbToBytes(200) - ) + private val lruCache = createDiskCache() operator fun get(url: String): File? { return lruCache.get(url)?.takeIfReadable() @@ -40,4 +38,19 @@ file.delete() return res } + + private fun createDiskCache(): DiskLruCache { + return DiskLruCache.create( + cacheDir.subdir(Cache.PAGES.dir), + getMaxCacheSize(maxSize = FileSizeUtils.mbToBytes(20), maxPercent = 70), + ) + } + + private fun getMaxCacheSize(maxSize: Long, maxPercent: Int): Long { + return runCatching { + val statFs = StatFs(cacheDir.absolutePath) + val size = maxPercent * statFs.blockCountLong * statFs.blockSizeLong + return minOf(size, maxSize) + }.getOrDefault(maxSize) + } } \ No newline at end of file ``` </details>
ztimms73 commented 2022-01-14 16:48:17 +00:00 (Migrated from github.com)

@nv95 ok, I will check this tomorrow)

@nv95 ok, I will check this tomorrow)
ztimms73 commented 2022-01-16 15:22:25 +00:00 (Migrated from github.com)

Same emulator (Nexus 4, Android 5.1), same issue even using a patch(
The emulator has enough free space on the internal storage. I tried changing the download locations, but the result is the same
On other versions of Android (>= SDK 23), downloading works without problems
Do you need more details from me on this issue?

Same emulator (Nexus 4, Android 5.1), same issue even using a patch( The emulator has enough free space on the internal storage. I tried changing the download locations, but the result is the same On other versions of Android (>= SDK 23), downloading works without problems Do you need more details from me on this issue?
Koitharu commented 2022-01-16 18:07:19 +00:00 (Migrated from github.com)

Tested on device with api 22, not reproducing(

Tested on device with api 22, not reproducing(
ztimms73 commented 2022-04-03 17:55:10 +00:00 (Migrated from github.com)

@yant0 can you check #134 and try to download chapter please?

@yant0 can you check #134 and try to download chapter please?
yant0 commented 2022-04-03 20:28:59 +00:00 (Migrated from github.com)

its spew this error :

android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{63c7377 u0 org.koitharu.kotatsu/.download.ui.service.DownloadService}
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1945)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	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:493)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

Same error occur wether i download a single chapter or multiple chapters

Asus. Android 10 corvus, no root.
i will try it with anothee phone soon

its spew this error : ``` android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{63c7377 u0 org.koitharu.kotatsu/.download.ui.service.DownloadService} at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1945) at android.os.Handler.dispatchMessage(Handler.java:107) 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:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924) ``` Same error occur wether i download a single chapter or multiple chapters Asus. Android 10 corvus, no root. i will try it with anothee phone soon
ztimms73 commented 2022-04-03 20:35:23 +00:00 (Migrated from github.com)

Uh oh...

Uh oh...
ztimms73 commented 2022-04-16 07:27:12 +00:00 (Migrated from github.com)

its spew this error :

android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{63c7377 u0 org.koitharu.kotatsu/.download.ui.service.DownloadService}
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1945)
	at android.os.Handler.dispatchMessage(Handler.java:107)
	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:493)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

Same error occur wether i download a single chapter or multiple chapters

Asus. Android 10 corvus, no root. i will try it with anothee phone soon

Fixed in 3.1.1. If there are any other problems with downloading, I will reopen the issue.

> its spew this error : > > ``` > android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{63c7377 u0 org.koitharu.kotatsu/.download.ui.service.DownloadService} > at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1945) > at android.os.Handler.dispatchMessage(Handler.java:107) > 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:493) > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924) > ``` > > Same error occur wether i download a single chapter or multiple chapters > > Asus. Android 10 corvus, no root. i will try it with anothee phone soon Fixed in 3.1.1. If there are any other problems with downloading, I will reopen the issue.
yant0 commented 2022-04-16 21:11:55 +00:00 (Migrated from github.com)

It fixed the error but is still not downloading properly.
https://bun.filedit.ch/erofHLJBTfHVNuhkkVy.mp4

Its fine with manually tappinh the missing chapter to download. Its not working when using multiple selection and using the download button on top right.

The 23.4kb file that the manga downloaded is only the cover... if that helps in anyway

It fixed the error but is still not downloading properly. https://bun.filedit.ch/erofHLJBTfHVNuhkkVy.mp4 Its fine with manually tappinh the missing chapter to download. Its not working when using multiple selection and using the download button on top right. The 23.4kb file that the manga downloaded is only the cover... if that helps in anyway
Koitharu commented 2022-04-17 07:08:08 +00:00 (Migrated from github.com)
@yant0 can you please try this build: https://github.com/nv95/Kotatsu/releases/tag/testbuild-170422
yant0 commented 2022-04-17 09:32:32 +00:00 (Migrated from github.com)

It works but theres some issue :

  • download notification stuck on 0%
  • the download continues on after 1 chapter (martial peak ch1 = 17 pages, on the data folder its 23 pages and still downloading)

another different behaviour is the chapter being downloaded in .jpeg instead of .cbz, i personally dont mind that.

It works but theres some issue : - download notification stuck on 0% - the download continues on after 1 chapter (martial peak ch1 = 17 pages, on the data folder its 23 pages and still downloading) another different behaviour is the chapter being downloaded in .jpeg instead of .cbz, i personally dont mind that.
ztimms73 commented 2022-06-14 19:34:37 +00:00 (Migrated from github.com)

Is the problem active at the moment?

Is the problem active at the moment?
yant0 commented 2022-07-15 15:24:25 +00:00 (Migrated from github.com)

Works now 👍 thank you

Works now 👍 thank you
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KotatsuApp/Kotatsu#50