Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash "Fatal Exception: java.lang.OutOfMemoryError" #80

Open
phlogistonCode opened this issue Aug 2, 2021 · 2 comments
Open

Crash "Fatal Exception: java.lang.OutOfMemoryError" #80

phlogistonCode opened this issue Aug 2, 2021 · 2 comments

Comments

@phlogistonCode
Copy link

phlogistonCode commented Aug 2, 2021

Добрый день.

Версия библиотеки:
'com.yandex.android:mobmetricalib:3.20.1'

В приложении есть 3 процесса: "main", "light" и "Metrica".

Метрика инициализируется во всех процессах:

YandexMetricaConfig.Builder builder = YandexMetricaConfig.newConfigBuilder(YANDEX_METRICA_API_KEY);
        if(BuildConfig.DEBUG)
            builder.withLogs();
        YandexMetricaConfig config = builder.build();
        YandexMetrica.activate(getApplicationContext(), config);
        YandexMetrica.enableActivityAutoTracking(this);

Firebase инициализируется везде кроме "Metrica" процесса:

if (!isMetricaProcess()) {
            FirebaseInit.init(this);
}

А Yandex Push SDK только в "main" процессе:

if (isMainProcess()) {
            YandexMetricaPush.init(getApplicationContext());
}

Android Manifest:

       <receiver
            android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND"
            android:process=":light"
            tools:node="replace">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </receiver>
        <service
            android:name=".services.FirebaseService"
            android:exported="false"
            android:process=":light">
            <intent-filter android:priority="-500">
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
        <!-- Yandex PushSDK -->
        <service android:name="com.yandex.metrica.push.firebase.MetricaMessagingService" tools:node="remove"/>

В Firebase сервисе при получении токена и сообщений мы перенаправляем данные в MetricaMessagingService:

    @Override
    public void onNewToken(String s) {
        super.onNewToken(s);
        SharedPrefs.getInstance().set(SharedPrefs.KEY_PUSH_TOKEN, s);
        new MetricaMessagingService().onNewToken(s);
    }

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);
        Timber.d("Push received");
        if(Notify.isOurPush(remoteMessage.getData())) {
            Timber.d("Push: Our");
            Notify.send(remoteMessage.getData());
        }else {
            Timber.d("Push: Yandex");
            new MetricaMessagingService().processPush(this, remoteMessage);
        }
    }

При этом достаточно большое кол-во крэшей видим в Firebase Crashlytics:

Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 1610 byte allocation with 8388608 free bytes and 22MB until OOM; failed due to fragmentation (required continguous free 16384 bytes for a new buffer where largest contiguous free 12288 bytes)
at java.lang.StringFactory.newStringFromBytes(StringFactory.java:79)
at java.lang.StringFactory.newStringFromBytes(StringFactory.java:53)
at java.lang.StringFactory.newStringFromBytes(StringFactory.java:45)
at com.yandex.metrica.impl.ob.za.a(SourceFile:4)
at com.yandex.metrica.impl.ob.fa.a(SourceFile:13)
at com.yandex.metrica.impl.ob.fa.(SourceFile:16)
at com.yandex.metrica.impl.ob.Ta.b(SourceFile:6)
at com.yandex.metrica.impl.ob.sd.a(SourceFile:56)
at com.yandex.metrica.impl.ob.V.reportError(SourceFile:3)
at com.yandex.metrica.impl.ob.Rs.run(SourceFile:1)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)

@ghost
Copy link

ghost commented Aug 2, 2021 via email

@Qhash
Copy link

Qhash commented Aug 13, 2021

Здравствуйте. Наблюдаем огромное количество похожих крешей в гугл консоли, после перехода с com.yandex.android:mobmetricalib:3.18.0 на com.yandex.android:mobmetricalib:3.20.1.

java.lang.OutOfMemoryError: 
  at java.lang.StringFactory.newStringFromChars (StringFactory.java:218)
  at java.lang.StringFactory.newStringFromBytes (StringFactory.java:203)
  at java.lang.StringFactory.newStringFromBytes (StringFactory.java:53)
  at java.lang.StringFactory.newStringFromBytes (StringFactory.java:45)
  at com.yandex.metrica.impl.ob.za.a (SourceFile:4)
  at com.yandex.metrica.impl.ob.fa.a (SourceFile:13)
  at com.yandex.metrica.impl.ob.fa.<init> (SourceFile:16)
  at com.yandex.metrica.impl.ob.Ta.b (SourceFile:6)
  at com.yandex.metrica.impl.ob.sd.a (SourceFile:56)
  at com.yandex.metrica.impl.ob.V.reportError (SourceFile:3)
  at com.yandex.metrica.impl.ob.Rs.run (SourceFile:1)
  at android.os.Handler.handleCallback (Handler.java:751)
  at android.os.Handler.dispatchMessage (Handler.java:95)
  at android.os.Looper.loop (Looper.java:154)
  at android.os.HandlerThread.run (HandlerThread.java:61)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants