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

feat(mobile): Manual asset upload #3445

Merged
merged 11 commits into from
Aug 6, 2023
Merged

feat(mobile): Manual asset upload #3445

merged 11 commits into from
Aug 6, 2023

Conversation

shenlong-tanwen
Copy link
Member

In this PR, I've added a basic support for #1684

Changes made in the PR

  • User can use the upload button from the Asset viewer to manually upload the single asset to the server or they can select at-most 30 assets from the timeline

Upload Asset Example Upload Asset from Timeline Example

  • DraggableScrollbarSheet in homepage is made dynamic to show actions related to the type of assets selected. If it contains only local assets, only the Share, Delete and Upload are displayed. If it contains both local and remote assets, favorite, add to album and other similar options are displayed.

Local Only Selection

Bottom Sheet Local Only Example

Local + Remote Selection

Upload Asset from Timeline Example

  • While testing, It seemed extremely hard to trigger force refresh from the homepage. Going through the code, found that the current interval between two successive refresh to force it was set to 2 seconds. I've bumped it to 4 seconds to make it a little bit more easier to trigger force refresh if required.

How Has This Been Tested?

✅ Multi asset upload from homepage
✅ Single asset upload from asset view

Potential Improvements

  • Currently, Favorite and other options to be performed on Remote only assets from the bottom sheet in the homepage are ignoring the local assets with a toast stating that they are not supported. The user can be presented with a prompt to upload them before performing the required action.
  • Local Notification handling for Asset upload progress, failure and error instead of showing a Toast
  • Need to analyze the performance impact of the app because of the change to make the homepage bottom sheet dynamic. From my basic testing, it did not seem to impact much in Performance. But it would be best to test it out once with large number of asset selections.

@vercel
Copy link

vercel bot commented Jul 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
immich ⬜️ Ignored (Inspect) Visit Preview Aug 6, 2023 2:37am

@alextran1502
Copy link
Contributor

Hello, what is the limitation of 30 uploads at once?

@shenlong-tanwen
Copy link
Member Author

shenlong-tanwen commented Jul 28, 2023

Hello, what is the limitation of 30 uploads at once?

It is a not a limitation of the stack but rather, a one set by us to easily handle cases such as:

  • App going into the background and thereby possibly killing off the upload in-between
  • Platform specific battery optimisation killing the app, etc.

I just felt it would be easier to handle such cases by asking the user to upload the assets in batches so that we can be sure that all the assets will be uploaded before the app is killed prematurely. Because with the current implementation, one can upload assets even without background / foreground sync enabled.

We can remove the hard limit, but we might need to improve the current implementation to make it resilient to above cases.

Even with the hard limit, it might be possible that the upload might be interrupted if a user is uploading a huge file and the app gets terminated somehow.

Copy link
Contributor

@martyfuhry martyfuhry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks cool! I didn't pull it down to try it out, but I left some initial thoughts above. I'm not super sure what the use case for this is, since I use the auto backup feature. I suppose there could be some confusion about uploading images manually versus automatically with this feature, but I doubt it's a big deal.

mobile/lib/modules/backup/providers/backup.provider.dart Outdated Show resolved Hide resolved
Comment on lines 105 to 107
initialChildSize: hasRemote ? 0.30 : 0.15,
minChildSize: 0.15,
maxChildSize: 0.57,
maxChildSize: hasRemote ? 0.57 : 0.15,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are for the DraggableScrollbarSheet related change where if all the selections are only local assets, we shouldn't let the user drag the bottom sheet and only present them with the options available for local only assets. Setting the initial and maximum values to the same seemed like an easier way to achieve it

mobile/lib/modules/home/views/home_page.dart Outdated Show resolved Hide resolved
@shenlong-tanwen shenlong-tanwen marked this pull request as ready for review July 29, 2023 07:40
@waclaw66
Copy link
Contributor

waclaw66 commented Aug 3, 2023

Looks cool! I didn't pull it down to try it out, but I left some initial thoughts above. I'm not super sure what the use case for this is, since I use the auto backup feature. I suppose there could be some confusion about uploading images manually versus automatically with this feature, but I doubt it's a big deal.

I'm happy for this feature. I don't/wan't to use automatic backup, manual selective upload of photos is my use case.

@alextran1502
Copy link
Contributor

Hello, I've finished the first round of testing of this PR

  • We don't have an indication of upload progress when uploading from the asset detail view. It can be confusing to the user if they are on a slower network, and it takes some time to upload the asset. What do you think?
  • After uploading a video, the state isn't updated correctly. Therefore you cannot upload other assets unless going to the backup page and tap on the Cancel button at the bottom of the page.

@shenlong-tanwen
Copy link
Member Author

We don't have an indication of upload progress when uploading from the asset detail view. It can be confusing to the user if they are on a slower network, and it takes some time to upload the asset. What do you think?

True. I'll check if we can reuse the notification handling used for background upload for manual uploads as well. It should be possible with a little refactoring.

@shenlong-tanwen
Copy link
Member Author

Refactored the PR to handle upload progress update using local notifications. New dependency flutter_local_notifications is added to make it easier to handle platform specific local notifications.

The notification works the same way as the change made in this PR - #781 except that the progress notifications are displayed always for manual uploads. Detailed notifications are displayed only when the user explicitly enables it under Notification settings. However, if a user is trying to upload only a single asset, we will display detailed notification for the single asset so as to provide better visibility when a user uploads a single large asset file. If the notification permission is not granted, the user will not be notified of the upload progress nor the final status of the upload.

The older platform specific code for handling background service upload notification can be refactored to use this plugin in a separate PR.

The other issue with App State not updating properly when uploading a video asset was due to us trying to show a toast when the context is unmounted. Since most part of them are refactored to use local notifications now, that issue should be fixed as well.

@alextran1502 alextran1502 enabled auto-merge (squash) August 6, 2023 02:39
@alextran1502 alextran1502 merged commit deaf81e into immich-app:main Aug 6, 2023
21 checks passed
@shenlong-tanwen shenlong-tanwen deleted the feat/mobile-single-upload branch August 6, 2023 11:14
@waclaw66
Copy link
Contributor

waclaw66 commented Sep 11, 2023

Could you please make the limit much higher or rather remove it completely?
I think it makes no different when the app is killed after 31 or 300 uploads.
Look at following usecase as I described above. I don't want to use automatic backup for many reasons. I want to upload daily shots (e.g. 300) in the evening. Now I have to select batch of 30 manually and let them upload and do the same 9times again. It's exhausting. When 31+ assets is selected to upload it refuses to start.
My proposal is to remove that limit completely or if you don't agree with my proposal upload first 30 of all selected (300) assets at least. Then I would need to select all day and click to upload 10times instead of manually selecting 300 images manually. It would be less painfull. Or couldn't be the list of selected assets handed to the automatic backup procedure?
Thanks in advance for considering the enhancement.

@daniele-athome
Copy link
Contributor

daniele-athome commented Sep 11, 2023

I second that. Battery optimizations don't kick in if there is a foreground service notification (on Android, I don't know about iOS though).
Random app kills due to low resources could happen anyway, I don't think we can blame the app for that (OOM killer is called on rare, very extreme circumstances).

@shenlong-tanwen
Copy link
Member Author

Could you please make the limit much higher or rather remove it completely? I think it makes no different when the app is killed after 31 or 300 uploads.

We can remove the limit for now and can re-add it in future if there are reports of the app getting killed. I'll handle this in the near future or you guys can feel free to open a PR to remove the hard limit. It is handled in the home_page.dart file

if (assets.length > 30) {
ImmichToast.show(
context: context,
msg: 'home_page_upload_err_limit'.tr(),
gravity: ToastGravity.BOTTOM,
);
} else {

@banto6
Copy link

banto6 commented Dec 22, 2023

Great feature, but currently the interaction is rather strange, will it be optimized for interaction in the future? For example, add an extra button to each album or homepage to realize the upload function

@shenlong-tanwen
Copy link
Member Author

shenlong-tanwen commented Dec 25, 2023

Great feature, but currently the interaction is rather strange, will it be optimized for interaction in the future? For example, add an extra button to each album or homepage to realize the upload function

I am planning to make this a bit more easier, yes. Adding an option to the local album page sounds like a great feature. Can you raise that as a separate FR in discussions?

@banto6
Copy link

banto6 commented Dec 25, 2023

Sure.

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

Successfully merging this pull request may close these issues.

None yet

7 participants