-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Feature/fluxc media upload service multiple uploads reattach progress #5780
Feature/fluxc media upload service multiple uploads reattach progress #5780
Conversation
…updates (reattach)
…y if content available
…to feature/fluxc-media-upload-service-multiple-uploads-reattach-progress
…nt or after view created for new posts - also clearing failed media ids from local array
…Content() then updating it in onMediaUploadProgress()
…gress when exiting it
…to feature/fluxc-media-upload-service-multiple-uploads-reattach-progress
…, to make upload progress visibility show accordingly
…, and passing the new post contents as a return value in the static method implementation in AztecEditorFragment
…g the list so we are sure to re-load posts once media are uploaded there
@@ -3,8 +3,8 @@ | |||
import org.wordpress.android.util.helpers.MediaFile; | |||
|
|||
public interface EditorMediaUploadListener { | |||
void onMediaUploadSucceeded(String localId, MediaFile mediaFile); | |||
void onMediaUploadSucceeded(String localId, EditorFragmentAbstract.MediaType mediaType, MediaFile mediaFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding an extra param here for the MediaType
seems redundant since we're already getting that from the MediaFile
, which we're also sending.
Could we make getEditorMimeType()
a (static) method of EditorFragmentAbstract
instead, and use that from AztecEditorFragment
and from EditPostActivity
? Then we can drop this parameter (we'll still need it in onMediaUploadFailed
below though, I guess).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 4417a4c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and thank you! nice improvement there)
FluxCUtils.mediaFileFromMediaModel(media)); | ||
} | ||
removeMediaFromPendingList(media); | ||
} | ||
|
||
private EditorFragmentAbstract.MediaType getEditorMimeType(boolean isVideo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a bit weird to keep calling getEditorMimeType(mediaFile.getVideo()
- it seems more natural to me to have getEditorMimeType(mediaFile)
, since that's what we're really doing (getting the media type of the media file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 4417a4c
I tested a variant of TEST B (background upload):
*The picture appears in the Here is the log:
|
Confirming what @daniloercoli is seeing - though only if I enable 'Don't keep activities'. (You're using the visual editor in that screenshot btw @daniloercoli - this branch doesn't have async support for the visual editor, only Aztec.) |
@@ -2440,6 +2448,7 @@ public void onMediaUploaded(MediaStore.OnMediaUploaded event) { | |||
onUploadSuccess(event.media); | |||
} | |||
else { | |||
AppLog.w(AppLog.T.MEDIA, "EDITPOSTACTIVITY: " + event.media.getId() + " - " + event.progress); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be a warning-level log. Also, is this log really necessary? We already generate quite a bit of logging per upload, with this there are three logs per tick:
05-05 08:27:02.034 31057-12701/org.wordpress.android.beta D/WordPress-API: Dispatching action: MediaAction-UPLOADED_MEDIA
05-05 08:27:02.082 31057-31057/org.wordpress.android.beta W/WordPress-MEDIA: EDITPOSTACTIVITY: 65 - 0.9653928
05-05 08:27:02.093 31057-31057/org.wordpress.android.beta D/WordPress-MEDIA: 65 - progressing 0.9653928
If they're helpful while working on async we could keep them but keep track that we should reduce them later - these logs make it into helpshift reports, and I think there's a size limit that can prevent earlier useful logs from being preserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! was just added to guide my own work, ditched it in 0cd3bc9
Right! I'm using the old visual editor. |
That's weird. My devices are experiencing some weird issues today due to activities that are not kept. Also, I don't have I think we should move much of the code outside the activity, since adding images to the editor could consume a lot of memory, (not counting when the user has enabled the Note: I would encourage to not test the app on emulator or Nexus 6P ;) We should try to test media related improvements on less powerful devices. |
…ype from the EditorMediaUploadListener interface
@daniloercoli summarizing the findings from the issue you ran into and what Mario and I discussed:
At one point I misunderstood your steps, and looked at exiting the editor while media was uploading (rather than leaving the editor). Trying this again now I realize there is a bug there:
We should change @daniloercoli could you confirm that you don't have any issues in this branch if you use Aztec and exit the editor before backgrounding the app? |
Right! everything is working as expected when I use Aztec. |
@@ -252,7 +252,7 @@ public void run() { | |||
while (count < 1.1) { | |||
sleep(500); | |||
|
|||
((EditorMediaUploadListener) mEditorFragment).onMediaUploadProgress(mediaId, count); | |||
((EditorMediaUploadListener) mEditorFragment).onMediaUploadProgress(mediaId, false, count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like the false
param should be here anymore (onMediaUploadProgress
wasn't changed) - also in two more places in this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct - addressed in fd1e412
for (Attributes attrs : content.getAllElementAttributes(uploadingPredicate)) { | ||
String localMediaId = attrs.getValue("data-wpid"); | ||
if (!TextUtils.isEmpty(localMediaId)) { | ||
mUploadingMediaProgressMax.put(localMediaId, new Float(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can drop an unnecessary boxing here and make a tiny optimization by just using 0f
instead of new Float(0)
(also clears a lint warning).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks - addressed in 4606f08
content.refreshText(); | ||
|
||
mUploadingMedia.put(localMediaId, MediaType.IMAGE); | ||
mUploadingMediaProgressMax.put(localMediaId, new Float(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above comment, can use 0f
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 4606f08
@@ -971,7 +1042,7 @@ public void onClick(DialogInterface dialog, int id) { | |||
// TODO: unmark video failed | |||
} | |||
mFailedMediaIds.remove(localMediaId); | |||
mUploadingMedia.put(localMediaId, mediaType); | |||
mUploadingMediaProgressMax.put(localMediaId, new Float(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above comment, can use 0f
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in 4606f08
content.refreshText(); | ||
|
||
// first obtain the latest maximum | ||
float maxProgressForLocalMediaId = mUploadingMediaProgressMax.get(localMediaId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can throw an NPE if the localMediaId
doesn't exist in mUploadingMediaProgressMax
(HashMap.get()
will return a null Float
, which will crash when unboxing into a float
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome catch - addressed in 1102c4f
Alright @mzorz, did another full pass and went through all your cases. Left a few small comments for things I missed earlier - should be good to go after those are fixed 👍 |
…oad to avoid potential NPE thanks @aforcier
ok! ready again @aforcier 🙇 |
Nice work @mzorz! |
70483ab
into
feature/fluxc-media-upload-service-multiple-uploads
This PR makes the multiupload capabilities of the MediaUploadService reflect on the UI when going out of the Editor and back (and images in a Post are still being uploaded).
TEST A (plain old single file upload):
TEST B (background upload):
TEST C (background upload - reattach progress):
TEST D (multiple upload):
TEST E (background upload - multiple upload):
TEST F (background upload - multiple upload - reattach progress):
TEST G (multicancel):
Known Issues
(Planning to work on these on separate PRs)
Different working copies of PostModel
2.a) image A gets replaced with the remote one, and this gets saved into the DB
2.b) image B gets replaced with the remote one, and this gets saved into the DB
We end up having a post with image A local, and image B remote, because what was saved last is 2.b) with a copy of the post that had both local images only.
How to solve this?
We need a way to ensure that all images get saved / replacing the post content.
Fortunately, the service runs as long as there’s stuff enqueued for upload.
See #5858
Random issues / enhancements
The profiling is missing the stop calls(see #5860)if I start a draft and do nothing, get out of the editor, it gets saved (it probably shouldn’t, should delete the post entirely). (see Don't keep an empty draft #5861)Trashed post reappearing (snackbar / refresh race condition) #5862
cc @aforcier