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

openPhotoGallery() restarting app on Android 9 #14024

Open
1 task done
FizixTiramu opened this issue Apr 21, 2024 · 7 comments
Open
1 task done

openPhotoGallery() restarting app on Android 9 #14024

FizixTiramu opened this issue Apr 21, 2024 · 7 comments
Labels
bug needs triage This issue hasn't been reviewed by maintainers

Comments

@FizixTiramu
Copy link

I have searched and made sure there are no existing issues for the issue I am filing

  • I have searched the existing issues

Description

We're getting an app restart on an Xiaomi A1 running Android 9 when Ti.Media.openPhotoGallery() is called.

Behaviour:
Photo gallery opens, when the photo gallery is retracted (either by cancelling or selecting a photo) the app restarts. Checking the console on LiveView it appears that the live view disconnects a moment after the photo gallery has opened. So it looks like the app is going into background refresh when the gallery is open.

Other than the liveview disconnecting when using live view, there are no error messages or anything appearing in the console, the app just restarts when the gallery is closed.

Note: This happens with regular builds and in live view.

Frequency:
Typically 1 in 5 gallery openings will lead to a restart, once a restart has occurred it will continue restarting every time.

Expected Behavior

App shouldn't background restart

Actual behavior

App restarts when photo gallery is opened.

Reproducible sample

Ti.Media.openPhotoGallery({
			success: function(result) {
				Ti.API.info('Image Selected');

				ui.gallery.imageEditor(result); // This is our image preview and editor which is shown after selection, we arent getting this far on this particular device
			},
			cancel: function(e){
				Ti.API.info('CANCELLED');
			},
			error: function(e){
				Ti.API.info('ERROR');
			},
			allowMultiple: false,
			allowEditing: false,
			mediaTypes: Ti.Media.MEDIA_TYPE_PHOTO,
			autohide: true
		});

Steps to reproduce

Not sure whether this is isolated to an Android version or something to do with this device. The code runs fine on Android 11+ devices. We use this for testing older Android versions, perhaps Android 9 related?

Platform

Android

SDK version you are using

12.3.0.GA

Alloy version you are using

No response

@FizixTiramu FizixTiramu added bug needs triage This issue hasn't been reviewed by maintainers labels Apr 21, 2024
@m1ga
Copy link
Contributor

m1ga commented Apr 21, 2024

sounds more like a memory issue. Please try to run it with -l traceand without liveview. You can also start adb logcat on a different terminal and look for a crashlog there. Thats the core log of your device and it should show something if it is SDK related. For memory you could attach Android Studio and analyse the memory in there

edit: some older phones have those memory issues as you can see here: https://stackoverflow.com/questions/40357163/android-app-restarts-during-gallery-intent

@FizixTiramu
Copy link
Author

sounds more like a memory issue. Please try to run it with -l traceand without liveview. You can also start adb logcat on a different terminal and look for a crashlog there. Thats the core log of your device and it should show something if it is SDK related. For memory you could attach Android Studio and analyse the memory in there

edit: some older phones have those memory issues as you can see here: https://stackoverflow.com/questions/40357163/android-app-restarts-during-gallery-intent

Thanks M1ga,

I see, it seems odd that the photo picker would do this when nothing else does though. I'll try your suggestion and try trimming/optimising anything that might be boosting the memory footprint around that process.

@m1ga
Copy link
Contributor

m1ga commented Apr 22, 2024

the photo picker is loading externally over your app and if memory gets low your app is killed in the background. The SO post is a native app with the same error so it's not Titanium exclusive but of course Ti will add some more memory overhead around your app compared to a native app so it's more likely to happen there

@FizixTiramu
Copy link
Author

the photo picker is loading externally over your app and if memory gets low your app is killed in the background. The SO post is a native app with the same error so it's not Titanium exclusive but of course Ti will add some more memory overhead around your app compared to a native app so it's more likely to happen there

I see, that makes sense. I guess looking into logs deeper and optimising the app where possible might be in order then. Thanks for the explanation.

@FizixTiramu
Copy link
Author

I appreciate this likely isnt Titanium, but I have this from the logs, could it be related? There is a note about memory wastage.

We're using the following modules:
ti.playservices
firebase.cloudmessaging
ti.documentpicker
ti.map

[WARN] �� � W/zix.linguastor: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
[WARN] �� � W/zix.linguastor: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
[INFO] �� � DynamiteModule: Selected remote version of com.google.android.gms.maps_core_dynamite, version >= 240506504
[INFO] �� � I/Google Android Maps SDK: Google Play services client version: 12451000
[INFO] �� � I/Google Android Maps SDK: Google Play services package version: 241217031
[INFO] �� � I/Google Android Maps SDK: Google Play services maps renderer version(maps_core): 240506504
[WARN] �� � System: ClassLoader referenced unknown path:
[WARN] �� � W/zix.linguastor: Accessing hidden method Ldalvik/system/VMStack;->getStackClass2()Ljava/lang/Class; (greylist, reflection, allowed)
[INFO] �� � TetheringManager: registerTetheringEventCallback:com.fizix.linguastorm
[WARN] �� � libEGL: EGLNativeWindowType 0x781dca5010 disconnect failed
[WARN] �� � DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
[WARN] �� � W/zix.linguastor: ClassLoaderContext classpath size mismatch. expected=11, found=4 (DLC[];PCL[base.apk*926570968:base.apk!classes2.dex*3414826461:base.apk!classes3.dex*3370080120:base.apk!classes4.dex*1898825382:base.apk!classes5.dex*621742052:base.apk!classes6.dex*3663555383:base.apk!classes7.dex*4172964313:base.apk!classes8.dex*2823879257:base.apk!classes9.dex*1443633717:base.apk!classes10.dex*2734267854:base.apk!classes11.dex*1697299821]{PCL[/system/framework/org.apache.http.legacy.jar*876722329]#PCL[/system/framework/com.android.media.remotedisplay.jar*1573936315]#PCL[/system/framework/com.android.location.provider.jar*1664931834]#PCL[/system/framework/org.apache.http.legacy.jar*876722329]} | DLC[];PCL[/data/app/~~Bz38Bswga7SL_hRKjXrn0w==/com.fizix.linguastorm-9wkt8QD7991qwh5OTeI_xw==/base.apk*3150345773:/data/app/~~Bz38Bswga7SL_hRKjXrn0w==/com.fizix.linguastorm-9wkt8QD7991qwh5OTeI_xw==/base.apk!classes2.dex*2770389314:/data/app/~~Bz38Bswga7SL_hRKjXrn0w==/com.fizix.linguastorm-9wkt8QD7991qwh5OTeI_xw==/base.apk!classes3.dex*3790764676:/data/app/~~Bz38Bswga7SL_hRKjXrn0w==/com.fizix.linguastorm-9wkt8QD7991qwh5OTeI_xw==/base.apk!classes4.dex*2206055240]{PCL[/system/framework/org.apache.http.legacy.jar*876722329]})
[WARN] �� � W/zix.linguastor: Found duplicate classes, falling back to extracting from APK : /data/app/~~82xeKDQoI991Z9xqS-aWKw==/com.google.android.gms--t2JJwg7laNRO3XKF8-HNg==/split_GoogleCertificates.apk
[WARN] �� � W/zix.linguastor: NOTE: This wastes RAM and hurts startup performance.
[WARN] �� � W/zix.linguastor: Found duplicated class when checking oat files: 'Landroid/support/v4/graphics/drawable/IconCompatParcelizer;' in /data/app/~~82xeKDQoI991Z9xqS-aWKw==/com.google.android.gms--t2JJwg7laNRO3XKF8-HNg==/split_GoogleCertificates.apk and /data/app/~~Bz38Bswga7SL_hRKjXrn0w==/com.fizix.linguastorm-9wkt8QD7991qwh5OTeI_xw==/base.apk
[WARN] �� � ProxyAndroidLoggerBackend: Too many Flogger logs received before configuration. Dropping old logs.
[WARN] �� � ProxyAndroidLoggerBackend: Too many Flogger logs received before configuration. Dropping old logs.
[WARN] �� � ProxyAndroidLoggerBackend: Too many Flogger logs received before configuration. Dropping old logs.
[WARN] �� � Gralloc4: allocator 3.x is not supported
[WARN] �� � Gralloc3: allocator 3.x is not supported
[WARN] �� � ProxyAndroidLoggerBackend: Too many Flogger logs received before configuration. Dropping old logs.
[WARN] �� � ProxyAndroidLoggerBackend: Too many Flogger logs received before configuration. Dropping old logs.
[ERROR] �� �BufferQueueProducer: [SurfaceTexture-0-9745-0](id:261100000000,api:0,p:-1,c:9745) disconnect: not connected (req=1)
[WARN] �� � libEGL: EGLNativeWindowType 0x7830cef010 disconnect failed

@m1ga
Copy link
Contributor

m1ga commented Apr 23, 2024

found the same for flutter:
https://stackoverflow.com/questions/78228441/firebase-core-found-duplicate-classes-no-package-id-7a-found-for-id-0x7a0b
flutter/flutter#136286
but no answer there. The SO post uses firebase too so that might be a common thing here. Don't see anything in there that would make me look into the SDK at the moment.

Android Studio Debug tools or something like https://square.github.io/leakcanary/ might be something worth looking at. You can add

dependencies {
  // debugImplementation because LeakCanary should only run in debug builds.
  debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
}

to your apps build.gradle file and it will look memory leaks. And for studio: open build/android in Android studio and then build a debug version to your device. After that look at the profiler menu to see you memory levels

@FizixTiramu
Copy link
Author

found the same for flutter: https://stackoverflow.com/questions/78228441/firebase-core-found-duplicate-classes-no-package-id-7a-found-for-id-0x7a0b flutter/flutter#136286 but no answer there. The SO post uses firebase too so that might be a common thing here. Don't see anything in there that would make me look into the SDK at the moment.

Android Studio Debug tools or something like https://square.github.io/leakcanary/ might be something worth looking at. You can add

dependencies {
  // debugImplementation because LeakCanary should only run in debug builds.
  debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
}

to your apps build.gradle file and it will look memory leaks. And for studio: open build/android in Android studio and then build a debug version to your device. After that look at the profiler menu to see you memory levels

Thanks.

Neah I think you're right that it probably isn't SDK related, I wondered if it was maybe module related and wanted some guidance is all. Thanks for this, appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage This issue hasn't been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants