Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

App freezes after downloading tiles, pausing and resuming #14740

Closed
tobrun opened this issue May 23, 2019 · 4 comments · Fixed by #15330
Closed

App freezes after downloading tiles, pausing and resuming #14740

tobrun opened this issue May 23, 2019 · 4 comments · Fixed by #15330
Assignees
Labels
Android Mapbox Maps SDK for Android Core The cross-platform C++ core, aka mbgl high priority offline
Milestone

Comments

@tobrun
Copy link
Member

tobrun commented May 23, 2019

Capturing from a user who is able to reproduce a application freeze with the following setup:

  • download a large region
  • wait for at least 65000 resource downloads
  • pause download
  • resume download
  • when it the download comes to the point to start downloading again, the application freezes.

The issue can be reproduced with https://github.com/mapbox/mapbox-gl-native/tree/tvn-offline-freeze:

  • Open up Download region example
  • press Start button and wait (the region will be paused and resumed automatically).

I validated the Android file source activation and that was valid. Can't find anything else in the Android code that would be responsible for causing this behavior.

cc @tmpsantos

@tmpsantos
Copy link
Contributor

Something odd I noticed when debugging this is that Android is calling pause on the file source when deactivating a region. Is there a reason for that?

@tmpsantos
Copy link
Contributor

One thing we are suspecting about this issue is that the status of an offline region in core is getting out of sync with the Android SDK.

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Jul 31, 2019
@tobrun
Copy link
Member Author

tobrun commented Jul 31, 2019

Been retesting this issue and hitting the following crash:

********** Crash dump: **********
Build fingerprint: 'google/sailfish/sailfish:10/QPP5.190530.014/5691763:user/release-keys'
pid: 18938, tid: 20373, name: DefaultFileSour  >>> com.mapbox.mapboxsdk.testapp <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x18
Stack frame #00 pc 0000000000162ce4  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine mbgl::util::Timer::Impl::stop() at /home/nurbot/ws/mapbox-gl-native/platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/debug/arm64-v8a/../../../../../src/timer.cpp:31
Stack frame #01 pc 0000000000162aa0  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine mbgl::util::Timer::Impl::start(std::__ndk1::chrono::duration<long long, std::__ndk1::ratio<1l, 1000000000l> >, std::__ndk1::chrono::duration<long long, std::__ndk1::ratio<1l, 1000000000l> >, std::__ndk1::function<void ()>&&) at /home/nurbot/ws/mapbox-gl-native/platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/debug/arm64-v8a/../../../../../src/timer.cpp:20
Stack frame #02 pc 0000000000162a40  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine mbgl::util::Timer::start(std::__ndk1::chrono::duration<long long, std::__ndk1::ratio<1l, 1000000000l> >, std::__ndk1::chrono::duration<long long, std::__ndk1::ratio<1l, 1000000000l> >, std::__ndk1::function<void ()>&&) at /home/nurbot/ws/mapbox-gl-native/platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/debug/arm64-v8a/../../../../../src/timer.cpp:67
Stack frame #03 pc 0000000000b13c44  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine mbgl::OnlineFileRequest::schedule(std::experimental::optional<std::__ndk1::chrono::time_point<std::__ndk1::chrono::system_clock, std::__ndk1::chrono::duration<long long, std::__ndk1::ratio<1l, 1l> > > >) at /home/nurbot/ws/mapbox-gl-native/platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/debug/arm64-v8a/../../../../../../default/src/mbgl/storage/online_file_source.cpp:399
Stack frame #04 pc 0000000000b14ca8  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine mbgl::OnlineFileRequest::completed(mbgl::Response) at /home/nurbot/ws/mapbox-gl-native/platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/debug/arm64-v8a/../../../../../../default/src/mbgl/storage/online_file_source.cpp:451
Stack frame #05 pc 0000000000b1b440  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine operator() at /home/nurbot/ws/mapbox-gl-native/platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/debug/arm64-v8a/../../../../../../default/src/mbgl/storage/online_file_source.cpp:119
Stack frame #06 pc 0000000000b1bee0  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine _ZNSt6__ndk18__invokeIRZN4mbgl16OnlineFileSource4Impl15activateRequestEPNS1_17OnlineFileRequestEEUlNS1_8ResponseEE_JS6_EEEDTclclsr3std6__ndk1E7forwardIT_Efp_Espclsr3std6__ndk1E7forwardIT0_Efp0_EEEOS9_DpOSA_ at /home/nurbot/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:4323
Stack frame #07 pc 0000000000b1bde4  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine std::__ndk1::__function::__func<mbgl::OnlineFileSource::Impl::activateRequest(mbgl::OnlineFileRequest*)::{lambda(mbgl::Response)#1}, std::__ndk1::allocator<{lambda(mbgl::Response)#1}>, void (mbgl::Response)>::operator()(mbgl::Response&&) at /home/nurbot/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/functional:1562
Stack frame #08 pc 0000000000a86fcc  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine std::__ndk1::function<void (mbgl::Response)>::operator()(mbgl::Response) const at /home/nurbot/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/functional:1924
Stack frame #09 pc 0000000000a86e9c  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine mbgl::HTTPRequest::async::{lambda()#1}::operator()() const at /home/nurbot/ws/mapbox-gl-native/platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/debug/arm64-v8a/../../../../../src/http_file_source.cpp:46
Stack frame #10 pc 0000000000a86e20  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine _ZNSt6__ndk18__invokeIRN4mbgl11HTTPRequest5asyncMUlvE_EJEEEDTclclsr3std6__ndk1E7forwardIT_Efp_Espclsr3std6__ndk1E7forwardIT0_Efp0_EEEOS5_DpOS6_ at /home/nurbot/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:4323
Stack frame #11 pc 0000000000a86d6c  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine std::__ndk1::__function::__func<mbgl::HTTPRequest::async::{lambda()#1}, std::__ndk1::allocator<mbgl::HTTPRequest::async>, void ()>::operator()() at /home/nurbot/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/functional:1562
Stack frame #12 pc 0000000000163310  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine std::__ndk1::function<void ()>::operator()() const at /home/nurbot/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/functional:1924
Stack frame #13 pc 0000000000691040  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine mbgl::util::AsyncTask::Impl::runTask() at /home/nurbot/ws/mapbox-gl-native/platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/debug/arm64-v8a/../../../../../src/async_task.cpp:36
Stack frame #14 pc 00000000000b6910  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine mbgl::util::RunLoop::Impl::processRunnables() at /home/nurbot/ws/mapbox-gl-native/platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/debug/arm64-v8a/../../../../../src/run_loop.cpp:176
Stack frame #15 pc 00000000000b7d3c  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine mbgl::util::RunLoop::run() at /home/nurbot/ws/mapbox-gl-native/platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/debug/arm64-v8a/../../../../../src/run_loop.cpp:222
Stack frame #16 pc 0000000000ad7400  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine operator() at /home/nurbot/ws/mapbox-gl-native/platform/android/MapboxGLAndroidSDK/.externalNativeBuild/cmake/debug/arm64-v8a/../../../../../../../include/mbgl/util/thread.hpp:69
Stack frame #17 pc 0000000000ad710c  /data/app/com.mapbox.mapboxsdk.testapp-DfLdmkXrv5hNWaYbuaML7g==/lib/arm64/libmapbox-gl.so (BuildId: 7cd08828e27986d64e259173c8c96ad4c0287590): Routine _ZNSt6__ndk18__invokeIZN4mbgl4util6ThreadINS1_17DefaultFileSource4ImplEEC1IJRKNS_10shared_ptrINS1_10FileSourceEEERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEEEESK_DpOT_EUlvE_JEEEDTclclsr3std6__ndk1E7forwardIT_Efp_Espclsr3std6__ndk1E7forwardIT0_Efp0_EEEOSP_DpOSQ_ at /home/nurbot/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include/type_traits:4323
Stack frame #18 pc 00000000000e372c  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: 77997b7202606ab2ce8b20d257c89e38)
Stack frame #19 pc 0000000000084004  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 77997b7202606ab2ce8b20d257c89e38)

This crash occurs at the same time as we would hit the freeze:

downloading a region of 69000 tiles and pausing it at 66000 + resuming after. The filesource goes through all resources and when it hits 66000 it crashes)

The trace points toOnlineFileRequest::schedule, more concretely when we try starting the timer:

     timer.start(timeout, Duration::zero(), [&] {
        impl.activateOrQueueRequest(this);
    });

timer.cpp:20 points to:

    void start(Duration timeout, Duration repeat_, std::function<void()>&& task_) {
        stop(); // this line
        ...
     }

@tobrun
Copy link
Member Author

tobrun commented Aug 2, 2019

When the freeze occurs, I'm seeing:

E/TaskServiceHelper: Cannot execute TaskName.UNKNOWN (or data got corrupted).
E/ThreadPoolDumper: Queue length for executor Background is now 96. Perhaps some tasks are too long, or the pool is too small.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android Core The cross-platform C++ core, aka mbgl high priority offline
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants