Unact / yandex_mapkit

Flutter implementation of YandexMapkit
MIT License
132 stars 151 forks source link

Map Stack error Flutter 3.x.x #228

Closed yeras-is closed 2 years ago

yeras-is commented 2 years ago

Hi, after upgrading the framework version, when I try to create screen using Stack and there is a Yandex map at the bottom, and modal windows on top, then I get error that Yandex Map is on top of Stack only on the Android platform, on iOS platform every thing is ok. I suspect the problem is hybrid rendering on the android platform, is there any solution for that?

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.2 21D49 darwin-arm, locale
    ru-KZ)
[✓] Android toolchain - develop for Android devices (Android SDK version
    32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
[✗] Chrome - develop for the web (Cannot find Chrome executable at
    /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Community Edition (version 2022.1)
[✓] VS Code (version 1.67.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.
ezze commented 2 years ago

We faced the same issue. Looks like map covers all the rest stacked Positioned widgets in Android (it doesn't matter whether I use emulator or run on a real device). It worked in Flutter 2 and still works in Flutter 3 in iOS. Here is simplified code snippet:

      Scaffold(
        key: _scaffoldKey,
        body: SafeArea(
          top: false,
          child: Stack(
            children: [
              YandexMap(onMapCreated: ...),
              Stack(
                children: [
                  if (widget.cancelable) Positioned(left: 8.w, top: 32.h, child: const AddressMapBackButton()),
                  Positioned(
                    bottom: media.padding.bottom + (_modalSize?.height ?? 0) + 16.h,
                    left: 16.w,
                    right: 16.w,
                    child: Column(...),
                  ),
                ],
              );
            ],
          ),
        ),
      ),

We're using yandex_mapkit@1.1.1 but upgrading to the recent version 2.0.5 also doesn't help.

DCrow commented 2 years ago

Hello!

Please include your error log and a sample reproducing said problem.

Also you can turn off hybrid rendering like this AndroidYandexMap.useAndroidViewSurface = false

yeras-is commented 2 years ago

Logs

Connecting to VM Service at ws://127.0.0.1:57366/Wrtim0rOOck=/ws
D/FRCPlugin( 8165): Sending fetchTimeout: 10
I/AppMetrica( 8165): Initializing of Metrica, Release type, Version 3.21.0, API Level 95, Dated 26.05.2021.
I/AppMetrica( 8165): Activate AppMetrica with APIKey 31c4116d-xxxx-xxxx-xxxx-xxxxxxxx8fd8
I/AppMetrica( 8165): [kz.magnum.go.android] : [31c4116d-xxxx-xxxx-xxxx-xxxxxxxx8fd8] Enable activity auto tracking
I/AppMetrica( 8165): [kz.magnum.go.android] : [31c4116d-xxxx-xxxx-xxxx-xxxxxxxx8fd8] Event received: Metrica installed
I/AppMetrica( 8165): Activate reporter with APIKey 20799a27-xxxx-xxxx-xxxx-xxxxxxxx4180
2
D/FRCPlugin( 8165): Sending fetchTimeout: 10
[MGO] route pushed: _CustomPageBasedPageRouteBuilder<dynamic>(CustomPage<dynamic>("AddressMapRoute", null, AddressMapRouteArgs{key: null, initialAddress: null, cancelable: false, onConfirm: null}), animation: AnimationController#20285(⏭ 1.000; paused; for _CustomPageBasedPageRouteBuilder<dynamic>(AddressMapRoute)))
W/yandex.maps( 8165): yandex::maps::runtime::api_key::ApiKey::setValue: API key is already set. Ignored.
W/yandex.maps( 8165): yandex::maps::runtime::locale::internal::LocaleManager::setLocale: Locale is already set. Ignored.
W/yandex.maps( 8165): yandex::maps::mapkit::layers::createGroundLayerUpdater: Layer: map, url: https://proxy.mob.maps.yandex.net:443/mapkit2/layers/2.x/map/tiles
W/yandex.maps( 8165): yandex::maps::mapkit::layers::createGroundLayerUpdater: Layer: sat, url: https://proxy.mob.maps.yandex.net:443/mapkit2/layers/2.x/sat/tiles
W/yandex.maps( 8165): yandex::maps::mapkit::layers::createGroundLayerUpdater: Layer: vskl2, url: https://proxy.mob.maps.yandex.net:443/mapkit2/layers/2.x/vskl2/tiles
W/yandex.maps( 8165): yandex::maps::mapkit::layers::createGroundLayerUpdater: Layer: vmap2, url: https://proxy.mob.maps.yandex.net:443/mapkit2/layers/2.x/vmap2/tiles
E/FrameEvents( 8165): updateAcquireFence: Did not find frame.
D/HostConnection( 8165): createUnique: call
D/HostConnection( 8165): HostConnection::get() New Host Connection established 0xb40000751d64aed0, tid 8351
D/HostConnection( 8165): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma ANDROID_EMU_hwc_multi_configs GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_0
E/FrameEvents( 8165): updateAcquireFence: Did not find frame.
W/yandex.maps( 8165): yandex::maps::runtime::logging::warn: Create OpenGl ES context version 3
D/EGL_emulation( 8165): eglCreateContext: 0xb40000751d649610: maj 3 min 0 rcv 3
D/EGL_emulation( 8165): eglMakeCurrent: 0xb40000751d649610: ver 3 0 (tinfo 0x7731a00280) (first time)
E/FrameEvents( 8165): updateAcquireFence: Did not find frame.
D/EGL_emulation( 8165): app_time_stats: avg=8.76ms min=2.71ms max=30.90ms count=48
W/yandex.maps( 8165): yandex::maps::mapkit::textures::Atlas::addTexture: Atlas: LayersAtlas. Page: 2 created. That could seriously decrease rendering speed
W/yandex.maps( 8165): yandex::maps::mapkit::textures::Atlas::addTexture: Atlas: LayersAtlas. Page: 3 created. That could seriously decrease rendering speed
E/yandex.maps( 8165): yandex::maps::mapkit::images::PolylineImageAtlas::add: Width of pattern is equal to 268, but should be power of 2. Added transparent padding
D/EGL_emulation( 8165): app_time_stats: avg=85.69ms min=3.40ms max=2978.73ms count=38
D/EGL_emulation( 8165): app_time_stats: avg=1694.64ms min=65.13ms max=4803.16ms count=3
W/yandex.maps( 8165): yandex::maps::mapkit::textures::Atlas::addTexture: Atlas: LayersAtlas. Page: 4 created. That could seriously decrease rendering speed
W/yandex.maps( 8165): yandex::maps::mapkit::textures::Atlas::addTexture: Atlas: LayersAtlas. Page: 5 created. That could seriously decrease rendering speed
W/yandex.maps( 8165): yandex::maps::mapkit::textures::Atlas::addTexture: Atlas: LayersAtlas. Page: 6 created. That could seriously decrease rendering speed
W/yandex.maps( 8165): yandex::maps::mapkit::textures::Atlas::addTexture: Atlas: LayersAtlas. Page: 7 created. That could seriously decrease rendering speed
W/yandex.maps( 8165): yandex::maps::mapkit::textures::Atlas::addTexture: Atlas: LayersAtlas. Page: 8 created. That could seriously decrease rendering speed

Sample

    return Scaffold(
      body: SafeArea(
        top: false,
        child: Stack(
          children: const [
            YandexMap(),
            Positioned(
              bottom: 40,
              right: 10,
              left: 10,
              child: ColoredBox(
                color: Colors.red,
                child: SizedBox(
                  height: 50,
                  width: 50,
                ),
              ),
            ),
          ],
        ),
      ),
    );
yeras-is commented 2 years ago

AndroidYandexMap.useAndroidViewSurface = false renders well

DCrow commented 2 years ago

Looking at your log I don't see any errors.

Your provided example also doesn't produce any errors, the red box appears in front of YandexMap as expected.

yeras-is commented 2 years ago

Do you used version 3 of flutter and android platform ?

DCrow commented 2 years ago

Yes, I tested using 3.0.0

prosky5 commented 2 years ago

AndroidYandexMap.useAndroidViewSurface = false

Example plz. Where I should paste this?

prosky5 commented 2 years ago

AndroidYandexMap.useAndroidViewSurface = false

Example plz. Where I should paste this?

Ok, I find out that this worked only with yandex_mapkit 2.0.0+

DCrow commented 2 years ago

@prosky5 You can paste this anywhere you like, only before using YandexMap widget.

DCrow commented 2 years ago

Closing since no reproducible example nor any error log has been given.