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

Fix race condition with GeometryTile::redoLayout #6263

Closed

Description

@jfirebaugh

Followup from #6201.

GeometryTile::redoLayout assumes that the worker has tile data from a previous call to worker.parseGeometryTile(...), but it also cancels the pending work request, which might be the very request that provides the worker with the tile data.

The way I'd like to fix this is to change the worker API to:

void setGeometryTileData(worker, data); // invoked in "fire and forget" fashion, not cancellable
Request startLayout(worker, ..., callback); // replaces parseGeometryTile, cancellable
Request continueLayout(worker, ..., callback); // replaces parsePendingGeometryTileLayers, cancellable

However, this depends on serial processing order of worker messages, so that we can guarantee that setGeometryTileData has completed by the time startLayout begins. We don't have this right now: it's possible for setGeometryTileData to get dispatched to one thread and startLayout to get dispatched to another and start executing before setGeometryTileData.

So I'm going to work on fixing #1471, which if implemented in the way I have in mind, would solve this problem as well.

Activity

  1. self-assigned this
    on Sep 6, 2016
  2. added
    release blocker
    Core
    on Sep 13, 2016
  3. jfirebaugh commented on Sep 13, 2016

    @jfirebaugh
    ContributorAuthor

    This is currently causing Android test failures, in the form of crashes with the following stack:

    Build fingerprint: 'google/shamu/shamu:5.1.1/LMY48Y/2364368:user/release-keys'
    pid: 12922, tid: 14188, name: Worker  >>> com.mapbox.mapboxsdk.testapp <<<
    signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    Stack frame #00 pc 00129614  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so: Routine mbgl::TileWorker::parseLayer(mbgl::style::Layer const*) at /bitrise/src/build/android-arm-v7/Debug/../../../src/mbgl/tile/tile_worker.cpp:139
    Stack frame #01 pc 00129530  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so: Routine mbgl::TileWorker::redoLayout(std::__ndk1::vector<std::__ndk1::unique_ptr<mbgl::style::Layer, std::__ndk1::default_delete<mbgl::style::Layer> >, std::__ndk1::allocator<std::__ndk1::unique_ptr<mbgl::style::Layer, std::__ndk1::default_delete<mbgl::style::Layer> > > >, mbgl::PlacementConfig) at /bitrise/src/build/android-arm-v7/Debug/../../../src/mbgl/tile/tile_worker.cpp:64
    Stack frame #02 pc 0013995c  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so: Routine mbgl::Worker::Impl::redoLayout(mbgl::TileWorker*, std::__ndk1::vector<std::__ndk1::unique_ptr<mbgl::style::Layer, std::__ndk1::default_delete<mbgl::style::Layer> >, std::__ndk1::allocator<std::__ndk1::unique_ptr<mbgl::style::Layer, std::__ndk1::default_delete<mbgl::style::Layer> > > >, mbgl::PlacementConfig, std::__ndk1::function<void (mapbox::util::variant<mbgl::TileParseResultData, std::exception_ptr>)>) at /bitrise/src/build/android-arm-v7/Debug/../../../src/mbgl/util/worker.cpp:59
    Stack frame #03 pc 00140200  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so: Routine operator()<mbgl::TileWorker *, std::__ndk1::vector<std::__ndk1::unique_ptr<mbgl::style::Layer, std::__ndk1::default_delete<mbgl::style::Layer> >, std::__ndk1::allocator<std::__ndk1::unique_ptr<mbgl::style::Layer, std::__ndk1::default_delete<mbgl::style::Layer> > > >, mbgl::PlacementConfig, (lambda at ../../../include/mbgl/util/work_task_impl.hpp:84:15)> at /bitrise/src/build/android-arm-v7/Debug/../../../src/mbgl/util/thread.hpp:68 (discriminator 56)
    Stack frame #04 pc 001400bc  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so: Routine _ZN4mbgl12WorkTaskImplIZNS_4util6ThreadINS_6Worker4ImplEE4bindIMS4_FvPNS_10TileWorkerENSt6__ndk16vectorINS9_10unique_ptrINS_5style5LayerENS9_14default_deleteISD_EEEENS9_9allocatorISG_EEEENS_15PlacementConfigENS9_8functionIFvN6mapbox4util7variantIJNS_19TileParseResultDataESt13exception_ptrEEEEEEEEEDaT_EUlDpOT_E_NS9_5tupleIJS8_SJ_SK_ZNS_6detail27packageArgumentsAndCallbackINS12_IJOS8_OSJ_RSK_RST_EEEJLj0ELj1ELj2EEEEDaNS9_10shared_ptrINS9_6atomicIbEEEEOSX_NS9_16integer_sequenceIjJXspT0_EEEEEUlS10_E0_EEEE6invokeIJLj0ELj1ELj2ELj3EEEEvNS1G_IjJXspT_EEEE at /bitrise/src/build/android-arm-v7/Debug/../../../include/mbgl/util/work_task_impl.hpp:43 (discriminator 54)
    Stack frame #05 pc 00143c90  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so: Routine mbgl::util::RunLoop::process() at /bitrise/src/build/android-arm-v7/Debug/../../../include/mbgl/util/run_loop.hpp:91 (discriminator 1)
    Stack frame #06 pc 00143b60  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so: Routine mbgl::util::RunLoop::run() at /bitrise/src/build/android-arm-v7/Debug/../../../platform/android/src/run_loop.cpp:228
    Stack frame #07 pc 00139fb4  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so: Routine void mbgl::util::Thread<mbgl::Worker::Impl>::run<std::__ndk1::tuple<>>(std::__ndk1::tuple<>&&, std::__ndk1::integer_sequence<unsigned int>) at /bitrise/src/build/android-arm-v7/Debug/../../../src/mbgl/util/thread.hpp:114
    Stack frame #08 pc 00139efc  /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so: Routine operator() at /bitrise/src/build/android-arm-v7/Debug/../../../src/mbgl/util/thread.hpp:98 (discriminator 1)
    Stack frame #09 pc 00016baf  /system/lib/libc.so (__pthread_start(void*)+30)
    Stack frame #10 pc 00014af3  /system/lib/libc.so (__start_thread+6)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Corecrashrelease blockerruntime styling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions