signalapp / Signal-Android

A private messenger for Android.
https://signal.org
GNU Affero General Public License v3.0
25.42k stars 6.09k forks source link

Android "Share" menu does not display the most recent/shared-to contacts #13398

Open breversa opened 7 months ago

breversa commented 7 months ago

Bug description

When sharing a file from any another app, the suggested Signal contacts are neither the most recent ones, nor the most shared-to ones.

Steps to reproduce

Actual result: The Android share menu suggests Signal contacts to share the file to, but these are not the most recent ones, nor the most frequently shared-to ones. They seem to be random. Also, the share menu icons take a few seconds to appear and be selectable.

Expected result: The Android menu should suggest the latest contacts I’ve interacted with, or those to whom I have the most frequently shared files with.

Screenshots

obscura1706781990793 (contacts blurred for privacy reasons)

Device info

Device: Samsung Galaxy S9 Android version: Android 11 (/e/OS 1.17) Signal version: 6.44.3

tedgravlin commented 7 months ago

I have the same issue, Pixel 7a Android 14 Logs: https://debuglogs.org/android/6.47.0/536158454094eb89bd6b8d4c580c488f4a1fc0226d5a634cd7f79a1fc6ee178b

sudansh commented 3 months ago

The sharesheet is managed by Android OS and we can't control the order in which those are shown. ref: https://developer.android.com/training/sharing/send

breversa commented 3 months ago

But the targets list has to be fed to/read by the Android Sharesheet somehow, hasn't it? There's a reason why the targets are displayed in that order (even if the reason doesn't make sense)... 🤔

alex-signal commented 3 months ago

The targets are fed but how they're cached and managed are on the OS.

genodeftest commented 3 months ago

Yeah, it seems like other apps have the same problems, see:

How about working around this issue by reducing the number of most recent contacts which is giving to the Android OS?

Currently, the contacts/groups I'm seeing in Android's share menu are chats number 20, 40 and 48 on Signal's main view ("Chats"), i.e., chats that are less important to me. Though the numbers are not fixed, i.e., if I archive chat number 19 on the list, Android's "Share" menu does not change. On the other hand, it does change if I archive one of the shown chats (20, 40, 48 in the original counting), Android's share menu gets updated, replacing the archived chats.

If I understand it correctly, Signal communicates the top chats to the Android OS, with the number determined by this code:

  public static int getMaxShortcuts(@NonNull Context context) {
    return Math.min(ShortcutManagerCompat.getMaxShortcutCountPerActivity(context), 150);
  }

(That code is used here)

It would be nice to know what this function returns in practice. Is it possible to attach a debugger such as gdb (via adb) to Signal running on my Android phone to figure this out? I couldn't find any guide/docs on Signal to do so and I'd expect I'd need debug symbols from Signal for that.

Anyway, assuming that the order of most recently used contacts, which Signal is reporting to Android (code here), is correct, it seems like Android is picking some arbitrary items off that list. In this case, this (Android) bug could be worked around by reducing the number of chats Signal reports to Android.

How about changing the limit from 150 to some lower value, e.g. 8? On a smartphone, depending on screen size and scale, Android will only display 3…5 most recent chats anyways. On a tablet it may or may not be more. So I'd expect there is no use in passing more than a dozen contacts to Android.

As a side-effect, Signal would not leak (most of) the chat list to Android so easily.

breversa commented 3 months ago

Thank you for this in-depth analysis and solution suggestion!

breversa commented 2 months ago

After updating my phone to Android 12 (/e/OS 2.1), I still have that issue, but the share menu appears without delay now, so that’s already a better thing.

breversa commented 2 months ago

Erratum: Following the upgrade to Android 12, the share menu is not empty, with no contact suggestion. :-/ It doesn't disturb me a lot ; at least it's much quicker that way.

stale[bot] commented 2 weeks ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

genodeftest commented 1 week ago

The issue is still present in Signal on Android version 7.14.2 and the code has not changed.

genodeftest commented 1 week ago

Can anyone who has signal installed on an android tablet (or a foldable phone or any other android device with a screen that is way larger than a regular smartphone) please check how many contacts/items are shown in the direct share panel? Do you see a number that is different from 4? Or do you also see 4 contacts to directly share with?

Why I'm asking: If Android will never show more than 4 items in the direct share panel, I would create a PR to change the code I mentioned above to make Signal only pass the top 4 contacts instead of the top 150.

breversa commented 5 days ago

Sorry, I don't have such a device but I wholeheartedly support your suggestion.