Significant downloadFile performance improvement in v8 despite using LegacyFilesystemImplementation #8307
SummaryAfter upgrading We're curious what might explain this performance gain. Environment
Test ResultsFile: 158MB video file (BigBuckBunny.mp4)
Code AnalysisIn v8.0.0, // FilesystemPlugin.kt (8.0.0)
@Deprecated("Use @capacitor/file-transfer plugin instead")
fun downloadFile(call: PluginCall) {
legacyImplementation?.downloadFile(call, bridge, emitter, callback)
}The buffer size (1024 bytes), progress throttle (100ms), and HTTP client ( QuestionSince
Any insight would be appreciated! 🙏 |
Replies: 2 comments
|
I found a potentially related issue: #6861 (Android Bridge Plugin Calls Queued - FileSystem.downloadFile blocking other requests) Could the bridge-level fix for this issue be contributing to the performance improvement we observed? 🤔 |
|
I checked whether #6861's fix is the explanation, and I don't think it is. That issue was about the Android bridge queuing other plugin calls behind a running Given the Kotlin download loop itself is confirmed identical, my best guess is this isn't a Capacitor code change at all, but an environment difference: Android's If you want to actually confirm which of these it is rather than guess: run both versions through Android Studio's Network Profiler (or a proxy like mitmproxy) and compare connection count/TLS renegotiation for the same 158MB request. If the v8 run reuses one keep-alive connection while v6 renegotiates per-chunk or opens multiple connections, that's your answer, and it'd be independent of anything in |
I checked whether #6861's fix is the explanation, and I don't think it is. That issue was about the Android bridge queuing other plugin calls behind a running
downloadFile, not aboutdownloadFile's own throughput. And looking atBridge.javaon the current main branch, plugin calls are still dispatched through a singleHandlerbacked by oneHandlerThread(taskHandler), not a thread pool, so whatever fix landed for #6861 didn't change the fundamental threading model you'd expect to explain a 3x raw transfer speedup. I couldn't find anything in the Capacitor core or Android CHANGELOGs between 6.x and 8.x that touches the bridge's networking path either.Given the Kotlin download loop itself …