来自后台的React-native应用程序延迟

时间:2018-07-30 21:54:14

标签: android react-native expo

我在Android上遇到了一个非常奇怪的UI错误。

从冷启动启动我的应用程序时,会立即呈现启动屏幕,然后按预期加载应用程序。

但是,如果我的应用程序在后台运行,则将其置于前台(通过点击主屏幕图标或通知)恰好有5秒的延迟。

让这种延迟变得奇怪的是,如果我点击冻结的屏幕,控制台事件会立即记录,甚至触摸事件也可以注册(因此应用程序实际上正在运行,尽管是看不见的),但是屏幕仍然冻结,显示为主屏幕或我以前使用的任何先前视图,持续5秒钟,然后该应用程序将按预期方式打开。

一致的5秒使我假设我错过了某个地方的超时,但是我已经从代码中删除了所有超时,并且仍然有5秒的延迟。

我正在运行Lollipop的实际设备上进行测试,并使用内置于expo并已分离的应用程序。我根本没有在iOS或我尝试过的Android模拟器中看到此问题。

我包括了build.gradle,因为我怀疑其中可能会发生一些可疑的事情。

任何想法都将不胜感激!

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

def keystorePropertiesFile = rootProject.file("keystore.properties");
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId 'com.company.app'
        targetSdkVersion 26
        versionCode 16
        versionName '0.1.6'
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        // Deprecated. Used by net.openid:appauth
        manifestPlaceholders = [
                'appAuthRedirectScheme': 'host.exp.exponent'
        ]
    }
    dexOptions {
        keepRuntimeAnnotatedClasses false
        // for: `Too many classes in --main-dex-list, main dex capacity exceeded`
        jumboMode true // suggested in react-native-twilio-video but may not be required?
        javaMaxHeapSize System.getenv("DISABLE_DEX_MAX_HEAP") ? null : "8g" // default from expo
    }
    signingConfigs {
        debug {
            storeFile file('../debug.keystore')
        }
        release {
          storeFile file(keystoreProperties['storeFile'])
          storePassword keystoreProperties['storePassword']
          keyAlias keystoreProperties['keyAlias']
          keyPassword keystoreProperties['keyPassword']
        }

    }
    flavorDimensions 'default'
    productFlavors {
        // Define separate dev and prod product flavors.
        dev {
            // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
            // to pre-dex each module and produce an APK that can be tested on
            // Android Lollipop without time consuming dex merging processes.
            minSdkVersion 21
            dimension 'default'
        }
        devRemoteKernel {
            minSdkVersion 21
            dimension 'default'
        }
        dev19 {
            // For debugging / development on older SDK versions. Increases build
            // time so use 'dev' if not running on older SDKs.
            minSdkVersion 21
            dimension 'default'
        }
        prod {
            // The actual minSdkVersion for the application.
            minSdkVersion 21
            dimension 'default'
        }
    }
    buildTypes {
        debug {
            debuggable true
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            signingConfig signingConfigs.release
        }
    }
    lintOptions {
        abortOnError false
    }
    packagingOptions {
        pickFirst "**"
    }
}

apply from: 'expo.gradle'

dependencies {
    implementation project(':react-native-firebase')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation'com.android.support:multidex:1.0.2'
    // Our dependencies
    // Our dependencies from ExpoView
    // DON'T ADD ANYTHING HERE THAT ISN'T IN EXPOVIEW. ONLY COPY THINGS FROM EXPOVIEW TO HERE.
    implementation'com.android.support:appcompat-v7:27.1.1'
    implementation'com.facebook.android:facebook-android-sdk:4.7.0'
    // implementation'com.facebook.android:audience-network-sdk:4.22.1'
    implementation('com.facebook.android:audience-network-sdk:4.22.1') {
        exclude module: 'play-services-ads'
    }
    compileOnly 'org.glassfish:javax.annotation:3.1.1'
    implementation'com.jakewharton:butterknife:7.0.1'
    implementation'de.greenrobot:eventbus:2.4.0'
    implementation'com.amplitude:android-sdk:2.9.2'
    // Be careful when upgrading! Upgrading might break experience scoping. Check with Jesse. See Analytics.resetAmplitudeDatabaseHelper
    implementation'com.squareup.picasso:picasso:2.5.2'
    implementation'com.google.android.gms:play-services-gcm:15.0.1'
    // implementation'com.google.android.gms:play-services-analytics:12.0.1'
    implementation'com.google.android.gms:play-services-maps:15.0.1'
    implementation'com.google.android.gms:play-services-auth:15.0.1'
    implementation'com.google.android.gms:play-services-location:15.0.1'
    implementation'com.google.android.gms:play-services-ads:15.0.1'
    annotationProcessor 'com.raizlabs.android:DBFlow-Compiler:2.2.1'
    implementation'com.raizlabs.android:DBFlow-Core:2.2.1'
    implementation'com.raizlabs.android:DBFlow:2.2.1'
    implementation'com.madgag.spongycastle:core:1.53.0.0'
    implementation'com.madgag.spongycastle:prov:1.53.0.0'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
    // debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
    implementation 'com.facebook.device.yearclass:yearclass:1.0.1'
    implementation 'commons-io:commons-io:1.3.2'
    implementation 'me.leolin:ShortcutBadger:1.1.4@aar'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.7'
    implementation 'com.yqritc:android-scalablevideoview:1.0.1'
    implementation 'commons-codec:commons-codec:1.10'
    implementation 'com.segment.analytics.android:analytics:4.3.0'
    implementation 'com.google.zxing:core:3.2.1'
    implementation 'net.openid:appauth:0.4.1'
    implementation('com.airbnb.android:lottie:2.5.5') {
        exclude group: 'com.android.support', module: 'appcompat-v7'
    }
    implementation'io.branch.sdk.android:library:2.17.1'
    implementation('io.nlopez.smartlocation:library:3.2.11') {
        transitive = false
    }
    implementation'com.android.support:exifinterface:27.1.1'
    implementation'com.squareup.okhttp3:okhttp:3.4.1'
    implementation'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
    implementation'com.squareup.okhttp3:okhttp-ws:3.4.1'
    implementation'com.squareup.okio:okio:1.9.0'
    // Testing
    androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.1'
    // We use a modified build of com.android.support.test:runner:1.0.1. Explanation in maven-test/README
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support:support-annotations:27.1.1'
    androidTestImplementation 'com.google.code.findbugs:jsr305:3.0.0'
    androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
    androidTestImplementation 'com.azimolabs.conditionwatcher:conditionwatcher:0.2'
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:1.10.19'
    testImplementation 'org.robolectric:robolectric:3.8'
    implementation('host.exp.exponent:expoview:28.0.0@aar') {
        transitive = true
    }

    implementation project(':react-native-twilio-video-webrtc')

    implementation "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.firebase:firebase-core:16.0.1"
    implementation "com.google.firebase:firebase-messaging:17.1.0"
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
    implementation 'com.android.support:design:27.1.1'
}

apply plugin: 'com.google.gms.google-services'

0 个答案:

没有答案