feat_: implement onLowMemory and onTrimMemory for android
Summary
this PR might help fixing issue #22463
when switch Status App in background, onLowMemory / onTrimMemory might be invoked, we get a chance to release some memory back to OS and keep our App stay alive longer rather than being killed.
this PR also added getHistoricalProcessExitReasons
relate status-go PR
logcat log that shows getHistoricalProcessExitReasons works:
2025-05-09 20:03:01.379 18950-18950/im.status.ethereum.debug I/MainApplication: Historical process exit reasons (last 5):
2025-05-09 20:03:01.379 18950-18950/im.status.ethereum.debug I/MainApplication: Exit reason #1:
2025-05-09 20:03:01.379 18950-18950/im.status.ethereum.debug I/MainApplication: Process: com.google.android.webview:sandboxed_process0:org.chromium.content.app.SandboxedProcessService0:0
2025-05-09 20:03:01.379 18950-18950/im.status.ethereum.debug I/MainApplication: Reason: 10
2025-05-09 20:03:01.379 18950-18950/im.status.ethereum.debug I/MainApplication: Timestamp: 1746791035537
2025-05-09 20:03:01.379 18950-18950/im.status.ethereum.debug I/MainApplication: Description: remove task
2025-05-09 20:03:01.379 18950-18950/im.status.ethereum.debug I/MainApplication: Importance: 400
2025-05-09 20:03:01.379 18950-18950/im.status.ethereum.debug I/MainApplication: PSS: 11132 KB
2025-05-09 20:03:01.379 18950-18950/im.status.ethereum.debug I/MainApplication: RSS: 98092 KB
Testing notes
see if PR build would keep our App stay alive longer in the background, if you can make Android system to trigger onLowMemory or onTrimMemory without using am that would be great! I haven't be able to reproduce ): However, when Status is in the background, you can run adb shell am send-trim-memory 22304 COMPLETE to trigger onLowMemory / onTrimMemory manually. 22304 should be replaced with actual pid of Status.
Platforms
- Android
Steps to test
- Open Status and login
- Keep Status running in the background
- Wait for some time and try to switch Status back
status: ready.
Jenkins Builds
Click to see older builds (16)
| :grey_question: | Commit | :hash: | Finished (UTC) | Duration | Platform | Result |
|---|---|---|---|---|---|---|
| :heavy_check_mark: | 6e9116e3 | #1 | 2025-04-23 10:59:05 | ~8 min | tests |
:page_facing_up:log |
| :heavy_check_mark: | 6e9116e3 | #1 | 2025-04-23 11:02:20 | ~11 min | android-e2e |
:robot:apk :calling: |
| :heavy_check_mark: | 6e9116e3 | #1 | 2025-04-23 11:03:09 | ~12 min | android |
:robot:apk :calling: |
| :heavy_check_mark: | 6e9116e3 | #1 | 2025-04-23 11:05:09 | ~14 min | ios |
:iphone:ipa :calling: |
| :heavy_check_mark: | ae01e601 | #2 | 2025-04-24 02:32:13 | ~5 min | tests |
:page_facing_up:log |
| :heavy_check_mark: | ae01e601 | #2 | 2025-04-24 02:36:47 | ~9 min | android-e2e |
:robot:apk :calling: |
| :heavy_check_mark: | ae01e601 | #2 | 2025-04-24 02:37:20 | ~10 min | android |
:robot:apk :calling: |
| :heavy_check_mark: | ae01e601 | #2 | 2025-04-24 02:38:12 | ~11 min | ios |
:iphone:ipa :calling: |
| :heavy_check_mark: | 09625ff8 | #3 | 2025-05-09 12:22:35 | ~5 min | tests |
:page_facing_up:log |
| :heavy_check_mark: | 09625ff8 | #3 | 2025-05-09 12:27:06 | ~9 min | android-e2e |
:robot:apk :calling: |
| :heavy_check_mark: | 09625ff8 | #3 | 2025-05-09 12:27:46 | ~10 min | android |
:robot:apk :calling: |
| :heavy_check_mark: | 09625ff8 | #3 | 2025-05-09 12:29:33 | ~12 min | ios |
:iphone:ipa :calling: |
| :heavy_check_mark: | 0115348a | #4 | 2025-05-19 11:55:06 | ~5 min | tests |
:page_facing_up:log |
| :x: | 0115348a | #4 | 2025-05-19 11:59:41 | ~9 min | android-e2e |
:page_facing_up:log |
| :x: | 0115348a | #4 | 2025-05-19 11:59:41 | ~9 min | android |
:page_facing_up:log |
| :heavy_check_mark: | 0115348a | #4 | 2025-05-19 12:02:30 | ~12 min | ios |
:iphone:ipa :calling: |
| :grey_question: | Commit | :hash: | Finished (UTC) | Duration | Platform | Result |
|---|---|---|---|---|---|---|
| :heavy_check_mark: | 3c94a83f | #5 | 2025-05-19 12:20:35 | ~4 min | tests |
:page_facing_up:log |
| :heavy_check_mark: | 3c94a83f | #5 | 2025-05-19 12:24:22 | ~8 min | android-e2e |
:robot:apk :calling: |
| :heavy_check_mark: | 3c94a83f | #5 | 2025-05-19 12:25:19 | ~9 min | android |
:robot:apk :calling: |
| :heavy_check_mark: | 3c94a83f | #5 | 2025-05-19 12:30:31 | ~14 min | ios |
:iphone:ipa :calling: |
| :heavy_check_mark: | b9ab48b4 | #6 | 2025-05-20 10:47:50 | ~5 min | tests |
:page_facing_up:log |
| :heavy_check_mark: | b9ab48b4 | #6 | 2025-05-20 10:50:45 | ~8 min | android |
:robot:apk :calling: |
| :heavy_check_mark: | b9ab48b4 | #6 | 2025-05-20 10:52:40 | ~10 min | android-e2e |
:robot:apk :calling: |
| :heavy_check_mark: | b9ab48b4 | #6 | 2025-05-20 10:56:44 | ~14 min | ios |
:iphone:ipa :calling: |
Tried running this PR build on Redmi 14R 5G with login status in background but didn't enable notification.
After 1 hour, it's been killed with :
04-24 09:16:13.828 2385 3182 I ActivityManager: Killing 12177:im.status.ethereum.pr/u0a291 (adj 901): camera boost
checked go logs, it seems onLowMemory and onTrimMemory hasn't been invoked.
to avoid android OS thinking Status as Cached Process, I'll try another around with enabling notification. When enabling notification, a foreground service will be created, in this case we should not see adj 901 anymore
Tried running this PR build on
Redmi 14R 5Gwith login status in background but didn't enable notification. After 1 hour, it's been killed with :04-24 09:16:13.828 2385 3182 I ActivityManager: Killing 12177:im.status.ethereum.pr/u0a291 (adj 901): camera boostchecked go logs, it seems
onLowMemory and onTrimMemoryhasn't been invoked.to avoid android OS thinking Status as
Cached Process, I'll try another around with enabling notification. When enabling notification, a foreground service will be created, in this case we should not seeadj 901anymore
in case of notification enabled, no killing after 5+ hours, switch Status back to foreground normally
@qfrank Hey! what is the state of the current PR? should it be moved to Review?
100% of end-end tests have passed
Total executed tests: 22
Failed tests: 0
Expected to fail tests: 0
Passed tests: 22
Not executed tests: 2
IDs of not executed tests: 702731,742910
Not executed tests (2)
Passed tests (22)
Click to expand
Class TestGroupChatMultipleDeviceMergedNewUI:
| 1. test_group_chat_join_send_text_messages_push, id: 702807 |
| Device sessions Device 1: Device 2: Device 3: |
Class TestWalletOneDeviceTwo:
| 1. test_wallet_add_remove_regular_account, id: 727231 |
| Device sessions Device 1: |
Class TestWalletMultipleDevice:
| 1. test_send_eth[Status Network Sepolia-0.0002], id: 727229 |
| Device sessions Device 1: Device 2: |
| 2. test_wallet_send_erc20_from_drawer[Optimism Sepolia-USD Coin-USDC-2-0.01], id: 727230 |
| Device sessions Device 1: Device 2: |
| 3. test_send_eth[Arbitrum Sepolia-0.0001], id: 742015 |
| Device sessions Device 1: Device 2: |
| 4. test_wallet_send_erc20_from_drawer[Sepolia-USD Coin-USDC-2-0.01], id: 742016 |
| Device sessions Device 1: Device 2: |
Class TestCommunityOneDeviceMerged:
| 1. test_community_copy_and_paste_message_in_chat_input, id: 702742 |
| Device sessions Device 1: |
Class TestCommunityMultipleDeviceMerged:
| 1. test_community_message_delete, id: 702839 |
| Device sessions Device 1: Device 2: |
| 2. test_community_message_send_check_timestamps_sender_username, id: 702838 |
| Device sessions Device 1: Device 2: |
| 3. test_community_one_image_send_reply_set_reaction, id: 702859 |
| Device sessions Device 1: Device 2: |
| 4. test_community_message_edit, id: 702843 |
| Device sessions Device 1: Device 2: |
Class TestWalletCollectibles:
| 1. test_wallet_send_collectible, id: 741840 |
| Device sessions Device 1: |
| 2. test_wallet_collectibles_balance, id: 741839 |
| Device sessions Device 1: |
| 3. test_wallet_collectible_send_from_expanded_info_view, id: 741841 |
| Device sessions Device 1: |
Class TestOneToOneChatMultipleSharedDevicesNewUi:
| 1. test_1_1_chat_send_image_save_and_share, id: 703391 |
| Device sessions Device 1: Device 2: |
| 2. test_1_1_chat_message_reaction, id: 702730 |
| Device sessions Device 1: Device 2: |
Class TestProfileMultipleDevices:
| 1. test_profile_change_profile_photo, id: 741969 |
| Device sessions Device 1: Device 2: |
| 2. test_profile_change_username, id: 741968 |
| Device sessions Device 1: Device 2: |
Class TestWalletOneDevice:
| 1. test_wallet_swap_flow_mainnet, id: 741555 |
| Device sessions Device 1: |
| 2. test_wallet_balance_mainnet, id: 740490 |
| Device sessions Device 1: |
| 3. test_wallet_bridge_flow_mainnet, id: 741612 |
| Device sessions Device 1: |
| 4. test_wallet_send_flow_mainnet, id: 741554 |
| Device sessions Device 1: |
@qfrank Hey! what is the state of the current PR? should it be moved to Review?
Hi @churik , I think it would be better to wait getting approval on corresponding status-go PR, then we're ready to test :)
Nice work @qfrank! Just a quick note, GC tweaks can also impact CPU. Have you checked if there's any spike in CPU usage caused by the forced GC?
There are some minor comments in the status-go PR, but LGTM overall 🚀
put Status into background, cpu usage is around 6%, after adb shell am send-trim-memory $PID COMPLETE, cpu usage goes up to 20%, but the duration of invocation is very short, around 78.223385ms on my device @ilmotta
Hi @qfrank !
Thanks for your PR. Can you please rebase go and mobile PR and also update files in mobile brunch so they have the same commits?
Hi @qfrank !
Thanks for your PR. Can you please rebase go and mobile PR and also update files in mobile brunch so they have the same commits?
Done :) @mariia-skrypnyk
88% of end-end tests have passed
Total executed tests: 88
Failed tests: 8
Expected to fail tests: 3
Passed tests: 77
IDs of failed tests: 703202,703133,742945,742942,702733,741841,702782,703194
IDs of expected to fail tests: 702844,742944,741924
Failed tests (8)
Click to expand
Class TestCommunityOneDeviceMerged:
| 1. test_restore_multiaccount_with_waku_backup_remove_profile_switch, id: 703133 |
Device 1: |
Class TestOneToOneChatMultipleSharedDevicesNewUi:
| 1. test_1_1_chat_text_message_delete_push_disappear, id: 702733 |
Device 1: Device 2: |
| 2. test_1_1_chat_emoji_send_reply_and_open_link, id: 702782 |
Device 1: Device 2: |
Class TestGroupChatMultipleDeviceMergedNewUI:
| 1. test_group_chat_reactions, id: 703202 |
Device 1: Device 2: Device 3: |
Class TestWalletConnectSignTransactions:
| 1. test_wallet_connect_multiple_profiles, id: 742942 |
Device 1: |
Class TestWalletConnectLoggedOut:
| 1. test_wallet_connect_logged_out, id: 742945 |
Device 1: |
Class TestCommunityMultipleDeviceMerged:
| 1. test_community_several_images_send_reply, id: 703194 |
Device 1: Device 2: |
Class TestWalletCollectibles:
| 1. test_wallet_collectible_send_from_expanded_info_view, id: 741841 |
Device 1: |
Expected to fail tests (3)
Click to expand
Class TestWalletConnectSignTransactions:
| 1. test_wallet_connect_sign_request_when_logged_out, id: 742944 |
[[Sign modal doesn't appear when logged out, https://github.com/status-im/status-mobile/issues/22586]] Device 1: |
Class TestCommunityMultipleDeviceMergedThree:
| 1. test_community_mobile_data_and_wi_fi_only_fetching, id: 741924 |
[[Community message can be fetched from offline when using mobile data]] Device 1: Device 2: |
Class TestCommunityMultipleDeviceMerged:
| 1. test_community_links_with_previews_github_youtube_twitter_gif_send_enable, id: 702844 |
[[Youtube links preview is not loaded on LambdaTest emulators, needs investigation]] Device 1: Device 2: |
Passed tests (77)
Click to expand
Class TestWalletOneDeviceTwo:
| 1. test_wallet_add_remove_regular_account, id: 727231 |
| Device sessions Device 1: |
Class TestWalletOneDeviceThree:
| 1. test_wallet_swap_dai_snt_real_tx, id: 742063 |
| Device sessions Device 1: |
Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:
| 1. test_1_1_chat_mute_chat, id: 703496 |
| Device sessions Device 1: Device 2: |
| 2. test_1_1_chat_is_shown_message_sent_delivered_from_offline, id: 702783 |
| Device sessions Device 1: Device 2: |
| 3. test_1_1_chat_delete_via_long_press_relogin, id: 702784 |
| Device sessions Device 1: Device 2: |
Class TestActivityMultipleDevicePR:
| 1. test_activity_center_reply_read_unread_delete_filter_swipe, id: 702947 |
| Device sessions Device 1: Device 2: |
Class TestWalletConnectSignTransactions:
| 1. test_wallet_connect_reject_sign_in_request, id: 742943 |
| Device sessions Device 1: |
| 2. test_wallet_connect_sign_transaction, id: 742901 |
| Device sessions Device 1: |
Class TestFallbackMultipleDevice:
| 1. test_fallback_add_key_pair, id: 741054 |
| Device sessions Device 1: Device 2: Device 3: |
| 2. test_fallback_sync_with_error, id: 740220 |
| Device sessions Device 1: Device 2: Device 3: |
| 3. test_fallback_with_correct_seed_phrase, id: 740221 |
| Device sessions Device 1: Device 2: Device 3: |
| 4. test_fallback_validate_seed_phrase, id: 740222 |
| Device sessions Device 1: Device 2: Device 3: |
Class TestWalletOneDevice:
| 1. test_wallet_swap_flow_mainnet, id: 741555 |
| Device sessions Device 1: |
| 2. test_wallet_balance_mainnet, id: 740490 |
| Device sessions Device 1: |
| 3. test_wallet_bridge_flow_mainnet, id: 741612 |
| Device sessions Device 1: |
| 4. test_wallet_send_flow_mainnet, id: 741554 |
| Device sessions Device 1: |
Class TestCommunityMultipleDeviceMergedTwo:
| 1. test_community_leave, id: 702845 |
| Device sessions Device 1: Device 2: |
| 2. test_community_mentions_push_notification, id: 702786 |
| Device sessions Device 1: Device 2: |
| 3. test_community_markdown_support, id: 702809 |
| Device sessions Device 1: Device 2: |
| 4. test_community_hashtag_links_to_community_channels, id: 702948 |
| Device sessions Device 1: Device 2: |
| 5. test_community_join_when_node_owner_offline, id: 703629 |
| Device sessions Device 1: Device 2: |
Class TestAndroid12:
| 1. test_create_account_android_12, id: 741806 |
| Device sessions Device 1: |
Class TestOneToOneChatMultipleSharedDevicesNewUi:
| 1. test_1_1_chat_edit_message, id: 702855 |
| Device sessions Device 1: Device 2: |
| 2. test_1_1_chat_message_reaction, id: 702730 |
| Device sessions Device 1: Device 2: |
| 3. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745 |
| Device sessions Device 1: Device 2: |
| 4. test_1_1_chat_pin_messages, id: 702731 |
| Device sessions Device 1: Device 2: |
| 5. test_1_1_chat_push_emoji, id: 702813 |
| Device sessions Device 1: Device 2: |
| 6. test_1_1_chat_send_image_save_and_share, id: 703391 |
| Device sessions Device 1: Device 2: |
Class TestWalletCustomParamOneDevice:
| 1. test_send_snt_custom_tx_params, id: 742910 |
| Device sessions Device 1: |
Class TestCommunityMultipleDeviceMerged:
| 1. test_community_emoji_send_copy_paste_reply, id: 702840 |
| Device sessions Device 1: Device 2: |
| 2. test_community_contact_block_unblock_offline, id: 702894 |
| Device sessions Device 1: Device 2: |
| 3. test_community_mark_all_messages_as_read, id: 703086 |
| Device sessions Device 1: Device 2: |
| 4. test_community_unread_messages_badge, id: 702841 |
| Device sessions Device 1: Device 2: |
| 5. test_community_message_delete, id: 702839 |
| Device sessions Device 1: Device 2: |
| 6. test_community_message_send_check_timestamps_sender_username, id: 702838 |
| Device sessions Device 1: Device 2: |
| 7. test_community_edit_delete_message_when_offline, id: 704615 |
| Device sessions Device 1: Device 2: |
| 8. test_community_message_edit, id: 702843 |
| Device sessions Device 1: Device 2: |
| 9. test_community_one_image_send_reply_set_reaction, id: 702859 |
| Device sessions Device 1: Device 2: |
Class TestAndroid13:
| 1. test_create_account_android_13, id: 741807 |
| Device sessions Device 1: |
Class TestProfileOneDevice:
| 1. test_profile_back_up_seed_phrase_validation, id: 741966 |
| Device sessions Device 1: |
| 2. test_profile_change_currency, id: 741967 |
| Device sessions Device 1: |
Class TestGroupChatMultipleDeviceMergedNewUI:
| 1. test_group_chat_join_send_text_messages_push, id: 702807 |
| Device sessions Device 1: Device 2: Device 3: |
| 2. test_group_chat_offline_pn, id: 702808 |
| Device sessions Device 1: Device 2: Device 3: |
| 3. test_group_chat_pin_messages, id: 702732 |
| Device sessions Device 1: Device 2: Device 3: |
| 4. test_group_chat_send_image_save_and_share, id: 703297 |
| Device sessions Device 1: Device 2: Device 3: |
| 5. test_group_chat_mute_chat, id: 703495 |
| Device sessions Device 1: Device 2: Device 3: |
Class TestActivityCenterContactRequestMultipleDevicePR:
| 1. test_activity_center_contact_request_accept_swipe_mark_all_as_read, id: 702851 |
| Device sessions Device 1: Device 2: |
| 2. test_activity_center_contact_request_decline, id: 702850 |
| Device sessions Device 1: Device 2: |
| 3. test_add_contact_field_validation, id: 702777 |
| Device sessions Device 1: Device 2: |
Class TestWalletMultipleDevice:
| 1. test_wallet_send_erc20_from_drawer[Optimism Sepolia-USD Coin-USDC (EVM)-2-0.01], id: 727230 |
| Device sessions Device 1: Device 2: |
| 2. test_send_eth[Arbitrum Sepolia-0.0001], id: 742015 |
| Device sessions Device 1: Device 2: |
| 3. test_send_eth[Status Network Sepolia-0.0002], id: 727229 |
| Device sessions Device 1: Device 2: |
| 4. test_wallet_send_erc20_from_drawer[Sepolia-USD Coin-USDC (EVM)-2-0.01], id: 742016 |
| Device sessions Device 1: Device 2: |
Class TestCommunityOneDeviceMerged:
| 1. test_community_copy_and_paste_message_in_chat_input, id: 702742 |
| Device sessions Device 1: |
| 2. test_community_navigate_to_channel_when_relaunch, id: 702846 |
| Device sessions Device 1: |
| 3. test_community_undo_delete_message, id: 702869 |
| Device sessions Device 1: |
| 4. test_community_mute_community_and_channel, id: 703382 |
| Device sessions Device 1: |
| 5. test_community_discovery, id: 703503 |
| Device sessions Device 1: |
Class TestActivityMultipleDevicePRTwo:
| 1. test_activity_center_admin_notification_accept_swipe, id: 702958 |
| Device sessions Device 1: Device 2: |
| 2. test_activity_center_mentions, id: 702957 |
| Device sessions Device 1: Device 2: |
| 3. test_activity_centre_contact_request_receiver_offline, id: 741809 |
| Device sessions Device 1: Device 2: |
Class TestWalletConnectDifferentNetworks:
| 1. test_wallet_connect_testnet_dapp, id: 742899 |
| Device sessions Device 1: |
| 2. test_wallet_connect_mainnet_dapp, id: 742900 |
| Device sessions Device 1: |
Class TestWalletConnectBaseChecks:
| 1. test_wallet_connect_disconnect, id: 742897 |
| Device sessions Device 1: |
| 2. test_wallet_connect_decline_and_select_account, id: 742898 |
| Device sessions Device 1: |
Class TestCommunityMultipleDeviceMergedThree:
| 1. test_community_send_message_from_offline, id: 741925 |
| Device sessions Device 1: Device 2: |
| 2. test_community_messaging_on_mobile_data, id: 741926 |
| Device sessions Device 1: Device 2: |
Class TestDeepLinksOneDevice:
| 1. test_links_open_universal_links_from_chat, id: 704613 |
| Device sessions Device 1: |
| 2. test_links_deep_links_profile, id: 702775 |
| Device sessions Device 1: |
| 3. test_deep_links_communities, id: 739307 |
| Device sessions Device 1: |
Class TestProfileMultipleDevices:
| 1. test_profile_change_accent_color, id: 741971 |
| Device sessions Device 1: Device 2: |
| 2. test_profile_change_profile_photo, id: 741969 |
| Device sessions Device 1: Device 2: |
| 3. test_profile_allow_new_contact_requests_toggle, id: 741972 |
| Device sessions Device 1: Device 2: |
| 4. test_profile_change_username, id: 741968 |
| Device sessions Device 1: Device 2: |
| 5. test_profile_set_bio, id: 741970 |
| Device sessions Device 1: Device 2: |
Class TestWalletCollectibles:
| 1. test_wallet_send_collectible, id: 741840 |
| Device sessions Device 1: |
| 2. test_wallet_collectibles_balance, id: 741839 |
| Device sessions Device 1: |