Increase logging around attachment compression/upload job lifecycle.

This commit is contained in:
Nicholas Tinsley
2024-07-16 17:31:45 -04:00
parent a950462451
commit e9c2f96bb9
5 changed files with 26 additions and 9 deletions

View File

@@ -1044,6 +1044,7 @@ class AttachmentTable(
@Throws(MmsException::class)
fun insertAttachmentForPreUpload(attachment: Attachment): DatabaseAttachment {
Log.d(TAG, "Inserting attachment $attachment for pre-upload.")
val result = insertAttachmentsForMessage(PREUPLOAD_MESSAGE_ID, listOf(attachment), emptyList())
if (result.values.isEmpty()) {

View File

@@ -26,6 +26,7 @@ import org.signal.libsignal.zkgroup.InvalidInputException;
import org.signal.libsignal.zkgroup.receipts.ReceiptCredentialPresentation;
import org.thoughtcrime.securesms.TextSecureExpiredException;
import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.attachments.AttachmentId;
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
import org.thoughtcrime.securesms.blurhash.BlurHash;
import org.thoughtcrime.securesms.contactshare.Contact;
@@ -248,15 +249,17 @@ public abstract class PushSendJob extends SendJob {
.toList());
return new HashSet<>(Stream.of(attachments).map(a -> {
AttachmentUploadJob attachmentUploadJob = new AttachmentUploadJob(((DatabaseAttachment) a).attachmentId);
final AttachmentId attachmentId = ((DatabaseAttachment) a).attachmentId;
Log.d(TAG, "Enqueueing job chain to upload " + attachmentId);
AttachmentUploadJob attachmentUploadJob = new AttachmentUploadJob(attachmentId);
jobManager.startChain(AttachmentCompressionJob.fromAttachment((DatabaseAttachment) a, false, -1))
.then(attachmentUploadJob)
.enqueue();
jobManager.startChain(AttachmentCompressionJob.fromAttachment((DatabaseAttachment) a, false, -1))
.then(attachmentUploadJob)
.enqueue();
return attachmentUploadJob.getId();
})
.toList());
return attachmentUploadJob.getId();
})
.toList());
}
protected @NonNull List<SignalServiceAttachment> getAttachmentPointersFor(List<Attachment> attachments) {

View File

@@ -67,7 +67,9 @@ public class MediaUploadRepository {
public void startUpload(@NonNull Collection<Media> mediaItems, @Nullable Recipient recipient) {
executor.execute(() -> {
for (Media media : mediaItems) {
Log.d(TAG, "Canceling existing preuploads.");
cancelUploadInternal(media);
Log.d(TAG, "Re-uploading media with recipient.");
uploadMediaInternal(media, recipient);
}
});
@@ -85,7 +87,9 @@ public class MediaUploadRepository {
boolean same = oldMedia.equals(newMedia) && hasSameTransformProperties(oldMedia, newMedia);
if (!same || !uploadResults.containsKey(newMedia)) {
Log.d(TAG, "Canceling existing preuploads.");
cancelUploadInternal(oldMedia);
Log.d(TAG, "Applying media updates.");
uploadMediaInternal(newMedia, recipient);
}
}
@@ -104,6 +108,7 @@ public class MediaUploadRepository {
}
public void cancelUpload(@NonNull Media media) {
Log.d(TAG, "User canceling media upload.");
executor.execute(() -> cancelUploadInternal(media));
}

View File

@@ -104,7 +104,9 @@ class MediaSelectionRepository(context: Context) {
val updatedMedia = oldToNewMediaMap.values.toList()
for (media in updatedMedia) {
Log.w(TAG, media.uri.toString() + " : " + media.transformProperties.map { t: TransformProperties -> "" + t.videoTrim }.orElse("null"))
val uri: Uri = media.uri
val transformProperties: Boolean? = media.transformProperties.map { it.videoTrim }.orElse(null)
Log.w(TAG, "$uri : trimmed=$transformProperties")
}
val singleRecipient: Recipient? = singleContact?.let { Recipient.resolved(it.recipientId) }

View File

@@ -189,12 +189,14 @@ class MediaReviewFragment : Fragment(R.layout.v2_media_review_fragment), Schedul
val multiselectLauncher = registerForActivityResult(multiselectContract) { keys ->
if (keys.isNotEmpty()) {
Log.d(TAG, "Performing send from multi-select activity result.")
performSend(keys)
}
}
val storiesLauncher = registerForActivityResult(storiesContract) { keys ->
if (keys.isNotEmpty()) {
Log.d(TAG, "Performing send from stories activity result.")
performSend(keys)
}
}
@@ -243,11 +245,15 @@ class MediaReviewFragment : Fragment(R.layout.v2_media_review_fragment), Schedul
} else if (sharedViewModel.isAddToGroupStoryFlow) {
MaterialAlertDialogBuilder(requireContext())
.setMessage(getString(R.string.MediaReviewFragment__add_to_the_group_story, sharedViewModel.state.value!!.recipient!!.getDisplayName(requireContext())))
.setPositiveButton(R.string.MediaReviewFragment__add_to_story) { _, _ -> performSend() }
.setPositiveButton(R.string.MediaReviewFragment__add_to_story) { _, _ ->
Log.d(TAG, "Performing send add to group story dialog.")
performSend()
}
.setNegativeButton(android.R.string.cancel) { _, _ -> }
.show()
scheduledSendTime = null
} else {
Log.d(TAG, "Performing send from send button.")
performSend()
}
}