Git Product home page Git Product logo

Comments (4)

DazzlingFame avatar DazzlingFame commented on August 26, 2024 1

Мои попытки фиксов V2:

removeViewAt в YamapViewManager в try catch

Решил попробовать полностью обернуть removeViewAt в try catch, чтобы понять, правильно ли локализовал место краша

    public void removeViewAt(YamapView parent, int index) {
      try {
        parent.removeChild(index);
        super.removeViewAt(parent, index);
        Log.d("!!!removeViewAt", "success");
      } catch (Exception e) {
        Log.d("!!!removeViewAt", e.getMessage());
      }
    }

Это не принесло результатов, лог в catch ни разу не отработал, хотя краш проявился

image

from react-native-yamap.

DazzlingFame avatar DazzlingFame commented on August 26, 2024

Мои попытки фиксов:

Обновление либы

Попробовал перейти на либу react-native-yamap-plus, в которой используется нативный map-kit версии 4.6.1. Проблема не пропала

Фикс в removeChild в YamapView

Стектрейс указывает на remove a view в ru.vvdev.yamap.view.YamapView

внутри YamapView видим метод removeChild, внутри которого уже реализованы проверки на наличие mapObject, те тут проблем возникать не должно

if (getChildAt(index) instanceof ReactMapObject) {
          final ReactMapObject child = (ReactMapObject) getChildAt(index);
          if (child == null) return;
          final MapObject mapObject = child.getMapObject();
          if (mapObject == null || !mapObject.isValid()) return;
          getMap().getMapObjects().remove(mapObject);
}

Однако на всякий случай пробуем отловить краш в try catch

    public void removeChild(int index) {
      try {
        if (getChildAt(index) instanceof ReactMapObject) {
          final ReactMapObject child = (ReactMapObject) getChildAt(index);
          if (child == null) return;
          final MapObject mapObject = child.getMapObject();
          if (mapObject == null || !mapObject.isValid()) return;

          Log.d("!!!removeChild success", String.valueOf(index));
          getMap().getMapObjects().remove(mapObject);
        }
      } catch (Exception e) {
        Log.d("!!!removeChild error", e.getMessage());
      }
    }

Но это не помогает, краши все равно воспроизводятся, лог removeChild error никогда не выводится

Фикс в removeViewAt в YamapViewManager

Тк падение не отловилось через try catch в YamapView, смотрю на removeViewAt, который последовательно вызывает

parent.removeChild(index);
super.removeViewAt(parent, index);

пробую проверить гипотезу, что parent.removeChild отрабатывает корректно, а super.removeViewAt падает

Изменение порядка вызовов

Обычно super методы вызываются в самом начале, пробуем изменить порядок вызовов

    public void removeViewAt(YamapView parent, int index) {
      super.removeViewAt(parent, index);
      parent.removeChild(index);
    }

Это не помогает

Опциональный вызов super.removeViewAt

попробовал возвращать булеан из removeChild, чтобы понимать снаружи, что удаление прошло корректно

    public boolean removeChild(int index) {
      try {
        if (getChildAt(index) instanceof ReactMapObject) {
          final ReactMapObject child = (ReactMapObject) getChildAt(index);
          if (child == null) return false;
          final MapObject mapObject = child.getMapObject();
          if (mapObject == null || !mapObject.isValid()) return false;

          getMap().getMapObjects().remove(mapObject);
          return true;
        }
      } catch (Exception e) {
        Log.d("!!!removeChild error", e.getMessage());
        return false;
      }
      return false;
    }

и далее вызывать super.removeViewAt только если removeChild вернул true, те удаление прошло успешно

    public void removeViewAt(YamapView parent, int index) {
      if (parent.removeChild(index)) {
          super.removeViewAt(parent, index);
      }
    }

Это тоже не помогло, краши остались

Дополнительная проверка на наличие чайлда через super

Перед вызовом super.removeViewAt делаю дополнительную проверку на наличие чайлда по индексу, по которому предполагается удаление

    public void removeViewAt(YamapView parent, int index) {
      if (parent.removeChild(index)) {
        if (super.getChildAt(parent, index) != null) {
          super.removeViewAt(parent, index);
        }
      }
    }

это тоже не помогает
Аналогично не помогает проверка на размер списка детей

    public void removeViewAt(YamapView parent, int index) {
      if (parent.removeChild(index)) {
        if (super.getChildCount(parent) > index) {
          super.removeViewAt(parent, index);
        }
      }
    }

from react-native-yamap.

DazzlingFame avatar DazzlingFame commented on August 26, 2024

Гипотезы и вопросы:

  • Нативный код падает, но приложение не крашится. Падает в каком-то потоке, который не критичен для работы JS?
  • Карта практически не падает на сильных устройствах, но зато стабильно падает, когда воспроизвожу на загруженном тормозящем эмуляторе. Проблема в каком-то race condition, который усугубляется на медленных девайсах?

from react-native-yamap.

aamagda avatar aamagda commented on August 26, 2024

По стектрейсу падает в этом месте react-native-reanimated.

🟢 Пробовали вариант с включением enableLayoutAnimations(true) из react-native-reanimated, проблема пропадает, видим динамику снижения крашей на пользователях.
🟡 Но при этом крайне редко бывает что не отрисовываются новые пины до тех пор пока снова не подвигаешь карту

🔴 Что еще пробовали, но не помогло

from react-native-yamap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.