S3
V: 2.6.16
Actual devices
No
No
Can you give us steps to reproduce with a minimal, complete, and verifiable example? Please include any specific network conditions that might be required to reproduce the problem.
Please include a stacktrace if applicable.
...
W/TransferService: Cannot find the S3 Client for the transfer: 2183624 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183625 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183626 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183627 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183628 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183629 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183630 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183631 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183632 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183633 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183634 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183635 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183636 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183637 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183638 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183639 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183640 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183641 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183642 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183643 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183644 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183645 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183646 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183647 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183649 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183650 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183651 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183652 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183653 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183654 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183655 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183656 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183657 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183658 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183659 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183660 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183661 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183662 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183663 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183664 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183665 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183666 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183667 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183668 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183669 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183670 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183671 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183672 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183673 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183674 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183675 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183676 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183677 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183678 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183679 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183680 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183681 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183682 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183683 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183684 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183685 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183686 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183687 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183688 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183689 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183690 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183691 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183692 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183693 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183694 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183695 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183696 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183697 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183698 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183699 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183700 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183701 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183702 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183703 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183704 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183705 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183706 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183707 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183708 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183709 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183710 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183711 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183712 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183713 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183714 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183715 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183716 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183717 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183718 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183719 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183720 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183721 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183722 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183723 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183724 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183725 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183726 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183727 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183728 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183729 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183730 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183731 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183732 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183733 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183734 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183735 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183736 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183822 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183823 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183824 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183825 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183826 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183827 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183828 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183829 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183830 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183831 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183832 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183833 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183834 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2183835 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2183836 Resume the transfer manually.
...
03-13 18:53:02.451 28665-29050/lar21.pontotel W/SQLiteConnectionPool: The connection pool for database '/data/data/lar21.pontotel/databases/awss3transfertable.db' has been unable to grant a connection to thread 833 (pool-7-thread-1) with flags 0x2 for 30.001001 seconds.
Connections: 1 active, 0 idle, 0 available.
Requests in progress:
executeForCursorWindow started 30003ms ago - running, sql="SELECT * FROM awstransfer WHERE (part_num=0) AND (state in (?))"
i receive this info everytime i start the upload:
03-14 13:38:20.503 29449-29561/lar21.pontotel W/SQLiteConnectionPool: The connection pool for database '/data/data/lar21.pontotel/databases/awss3transfertable.db' has been unable to grant a connection to thread 1759 (pool-5-thread-1) with flags 0x2 for 30.000002 seconds.
Connections: 1 active, 0 idle, 0 available.
Requests in progress:
executeForCursorWindow started 30000ms ago - running, sql="SELECT * FROM awstransfer WHERE (part_num=0) AND (state in (?))
impossible to do any query or something that use the awstransfer database
nothing works, its stay in this state forever
eg: transferUtility!!.getTransfersWithType(TransferType.UPLOAD) (the app never pass this call, it hangs in this method)
TransferUtility.builder().s3Client(getS3Client(context.getApplicationContext())
never getting done
Hi @defaultbr, Thank you for reporting to us. Sorry for the inconvenience caused. TransferService runs a jon periodically (default - 1-minute) where it queries the database for transfers that are in WAITING, WAITING_FOR_NETWORK, IN_PROGRESS and RESUMED_WAITING and resumes them if they are not running when a valid S3 client is present.
In your case, you are hitting this if check https://github.com/aws/aws-sdk-android/blob/master/aws-android-sdk-s3/src/main/java/com/amazonaws/mobileconnectors/s3/transferutility/TransferService.java#L462 because you do not have a S3 client for the transfer id in the in-memory map and the job skips resuming the transfers.
As a workaround, you can increase the time between two successive checks to avoid the race between the query which this job runs and the query that you run from the app.
https://docs.aws.amazon.com/aws-mobile/latest/developerguide/how-to-transfer-files-with-transfer-utility.html#native-transfer-utility-options
TransferUtilityOptions options = new TransferUtilityOptions();
options.setTransferServiceCheckTimeInterval(2 * 60 * 1000); // 2-minutes
TransferUtility transferUtility = TransferUtility.builder()
// Pass-in S3Client, Context, AWSConfiguration/DefaultBucket Name
.transferUtilityOptions(options)
.build();
You can set it to a value say 5-minutes to reduce the frequency of this check to happen.
Anyways, the connection should be closed by the job and returned to the connection pool. We are investigating why the connection is not closed in the while loop here: https://github.com/aws/aws-sdk-android/blob/master/aws-android-sdk-s3/src/main/java/com/amazonaws/mobileconnectors/s3/transferutility/TransferService.java#L457
Do you have the call to transferUtility!!.getTransfersWithType(TransferType.UPLOAD) when the app starts?
Hello @kvasukib thanks the answer, i changed the options, see my outputs
TransferUtilityOptions options = new TransferUtilityOptions();
options.setTransferServiceCheckTimeInterval(5 * 60 * 1000); // 5-minute
options.setTransferThreadPoolSize(999);
sTransferUtility = TransferUtility.builder().s3Client(getS3Client(context.getApplicationContext()))
.transferUtilityOptions(options)
.context(context)
.build();
} catch (Exception e) {
e.printStackTrace();
}
}
but still gave me this:
W/SQLiteConnectionPool: The connection pool for database '/data/data/lar21.pontotel/databases/awss3transfertable.db' has been unable to grant a connection to thread 1939 (pool-5-thread-1) with flags 0x2 for 30.001001 seconds.
Connections: 1 active, 0 idle, 0 available.
Requests in progress:
executeForCursorWindow started 30001ms ago - running, sql="SELECT * FROM awstransfer WHERE (part_num=0) AND (state in (?))"
and
W/TransferService: Cannot find the S3 Client for the transfer: 2182105 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182106 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182107 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182108 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182109 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182110 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182111 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182112 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182113 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182114 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182115 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182116 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182117 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182118 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182119 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182120 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182121 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182122 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182123 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182124 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182125 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182126 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182127 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182128 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182129 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182130 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182131 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182132 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182133 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182134 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182135 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182136 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182137 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182138 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182139 Resume the transfer manually.
W/TransferService: Cannot find the S3 Client for the transfer: 2182140 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182141 Resume the transfer manually.
Cannot find the S3 Client for the transfer: 2182142 Resume the transfer manually.
now its not hanging on TransferUtilityBuild, and its uploading ok, BUT after .upload, it takes about 2 minutes to really start uploading the file, in this moment this output happen Cannot find the S3 Client for the transfer: 2182105 Resume the transfer manually.
so i guess that transfer.upload method is triggering the resume task
Thank you @defaultbr for the reply. To avoid this job to kick in you can set the time interval to -1.
TransferUtilityOptions options = new TransferUtilityOptions();
options.setTransferServiceCheckTimeInterval(-1);
options.setTransferThreadPoolSize(4);
Can you give a try with -1 and see if the job doesn't kick in more than once? Also can you share the code where you construct the transfer utility object and start the upload?
@kvasukib hello, the result was the same, even using -1
Of course i can share:
ognitoCachingCredentialsProvider sCredProvider = new CognitoCachingCredentialsProvider(
context.getApplicationContext(),
"here is the identypool id",
Regions.US_EAST_1 // Region
ClientConfiguration clientConfiguration = new ClientConfiguration();
clientConfiguration.setConnectionTimeout(10000);
clientConfiguration.setSocketTimeout(10000);
clientConfiguration.setMaxConnections(1);
clientConfiguration.setMaxErrorRetry(0);
clientConfiguration.setEnableGzip(true);
AmazonS3Client sS3Client = new AmazonS3Client(getCredProvider(context.getApplicationContext()), clientConfiguration);
sS3Client.setRegion(Region.getRegion(Regions.US_EAST_1));
TransferUtilityOptions options = new TransferUtilityOptions();
options.setTransferServiceCheckTimeInterval(-1);
options.setTransferThreadPoolSize(4);
TransferUtility sTransferUtility = TransferUtility.builder().s3Client(getS3Client(context.getApplicationContext()))
.transferUtilityOptions(options)
.context(context)
.build();
obs: im using singleton pattern, so all the local variable are static and global in the real code
Thank you @defaultbr for the quick reply.
Can you turn on the debug log by enabling verbose/debug in the logcat window from Android Studio and give us the logs?
If you can, please share the source code of the app so that we can reproduce the issue by running the app on our side?
@kvasukib in the logcat has nothing more about it, just some "Background sticky concurrent mark sweep GC freed 23290(1657KB) AllocSpace object...." and a lot of garbage related to my app
i cant share the code :'(
now im testing more, in another device Moto G4 Plus with 2000 files in the folder was ok, started fast
maybe this is a issue with the device: Tablet DL 3410 (i will do more tests and post here ok?)
Thank you @defaultbr for the reply. Yes, you can perform more tests and give us the logs. I was mainly looking for the log messages from these lines:
This will help us find two things:
loadAndResumeTransfersFromDB ever exited/finished?loadAndResumeTransfersFromDB is waiting beacuse the first instance of loadAndResumeTransfersFromDB is still holding the connection to the database resulting in a potential deadlock.If you can give us a file of the complete logs from logcat that would help us narrow done the deadlock situation sooner.
@kvasukib nice, i will try to do a dump of the log for you soon
Hi @defaultbr, We have made an optimization to loadAndResumeTransfersFromDB to minimize the time holding the database connection. This should improve the time in starting successive uploads. This change was released on 03/15 in 2.6.17. Please give it a try and let us know any feedback you have. Thank you!
Hi @defaultbr, Checking to see if your app is working fine with the latest version. Please let us know fi you run into any issues or if you find any useful log information for debugging. Thanks.
Hi @kvasukib i don't know if transfer service error can put in this topic.
When i do upload and the app state is onBackground the transferObserver change state to "PAUSED" , the system android kill the TransferService after some seconds. It is my logcat:
03-30 22:14:03.072 1811-1844/system_process W/ActivityManager: Stopping service due to app idle: u0a91 -1m13s545ms com.robson.mandaaesportv/com.amazonaws.mobileconnectors.s3.transferutility.TransferService
03-30 22:14:03.073 30291-30291/com.robson.mandaaesportv I/TransferService: unregistering receiver
03-30 22:14:03.330 30291-30291/com.robson.mandaaesportv I/TransferService: Closing the database.
03-30 22:14:03.330 30291-30291/com.robson.mandaaesportv D/transfer_utility: state: PAUSED
Sdk version: 'com.amazonaws:aws-android-sdk-s3:2.6.+' and tried ''com.amazonaws:aws-android-sdk-s3:2.6.18''
Tested on: android studio emulator and real device asus zenfone 3
MyCode:
val s3Client = getS3ClientWithCredentialsProvider(getCredentialsProvider())
transferUtility = TransferUtility.builder().defaultBucket("${BUCKET_NAME}").s3Client(s3Client).context(applicationContext).build();
observerUtility = transferUtility?.upload("${FOLDER_NAME}/SP_MOBILE_${fileName}", file)
observerUtility?.setTransferListener(object : TransferListener {
override fun onStateChanged(id: Int, state: TransferState) {
Log.d("transfer_utility", "state: ${state}")
if (TransferState.COMPLETED == state) {
Log.d("transfer_utility", "completed")
Log.d("transfer_utility", "Bytes Transferrred: " + observerUtility?.getBytesTransferred());
Log.d("transfer_utility", "Bytes Total: " + observerUtility?.getBytesTotal());
val message = "Sent Message"
progressBar?.setVisibility(View.GONE)
spinner?.setVisibility(View.GONE)
spinner?.setClickable(false)
resumeOrPause.setVisibility(View.GONE)
thumbVideo.setClickable(true)
imageUpload.setVisibility(View.INVISIBLE)
editViewName.setFocusable(false)
finishNotification()
var video = Video("SP_MOBILE_$fileName", null, bitmapdata, Uri.parse(mediaPath), Calendar.getInstance(Locale.getDefault()).timeInMillis)
daoUtils!!.save(video)
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
}
}
override fun onProgressChanged(id: Int, bytesCurrent: Long, bytesTotal: Long) {
val percentDonef = (bytesCurrent.toFloat() / bytesTotal.toFloat()) * 100;
Log.d("transfer_utility", "onProgressChanged percentDoneInt: ${percentDonef.toInt()}")
publishProgress(percentDonef.toInt())
Log.d("transfer_utility", "bytesTotal: " + bytesTotal + " " + percentDonef.toInt() + "%");
}
override fun onError(id: Int, ex: Exception) {
Log.e("transfer_utility", "error", ex)
val message = ex.localizedMessage
progressBar?.setVisibility(View.GONE)
spinner?.setVisibility(View.GONE)
spinner?.setClickable(false)
thumbVideo.setClickable(true)
imageUpload.setVisibility(View.VISIBLE)
editViewName.setFocusable(true)
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
throw ex
}
})
Thank you @robsonn for reporting to us. In your case, what I can see is that the TransferService onDestroy is being called. In onDestroy we try to close the thread pool, pause all transfers, unregister the listener. (I can see this from your logs)
This means that Android is trying to kill the TransferService. One of the reasons the service could be killed is because of low memory in the device. Is your device running on low memory? Can you find any reason why Android is trying to kill your service?
Also are any transfers being active when the service is being killed?
Hello @kvasukib i will give a try to the changes and report when device get it,
i will try to figure why android is trying to kill it
thxxx
Thanks @kvasukib for the reply. The android memory is very big, my device is a asus zenfone 3 4gb android O and virtual is a nexus android O 2gb. The app doing one upload file not multiple.
In app, the notification or the activity may be consuming memory in background. I will clean(remove view button, progressbar and etc) the app and just start the transferListener in background. I will report you after this test.
Thank you @robsonn for the reply. Can you tell us the number of processors in your devices? You can get this by running Runtime.getRuntime().getAvailableProcessors() in your app.
Hi @kvasukib. I did what you say and rewrite the code, removing my notification and the update view progress. I put the runtime code on method onProgressChanged, it is running in my activity that extends AppCompatActivity and the android oreo sdk s3 2.6.+ nexus virtual
fun sendFileUpload() {
val file = File(mediaPath)
val fileName = "${editViewName.text}.${file.extension}"
val clientConfiguration = ClientConfiguration();
clientConfiguration.setConnectionTimeout(10000 * 3);
clientConfiguration.setSocketTimeout(10000 * 3);
clientConfiguration.setMaxConnections(1);
clientConfiguration.setMaxErrorRetry(0);
val s3Client = AmazonS3Client(getCredentialsProvider(), clientConfiguration)
//val s3Client = getS3ClientWithCredentialsProvider(getCredentialsProvider())
val blob = ByteArrayOutputStream()
bitmap!!.compress(Bitmap.CompressFormat.PNG, 0 /*ignored for PNG*/, blob)
val bitmapdata = blob.toByteArray()
transferUtility = TransferUtility.builder().defaultBucket("${BUCKET_NAME}").s3Client(s3Client).context(applicationContext).build();
transferUtility!!.getTransfersWithType((TransferType.UPLOAD))
observerUtility = transferUtility?.upload("${FOLDER_NAME}/SP_MOBILE_${fileName}", file)
override fun onStateChanged(id: Int, state: TransferState) {
Log.d("transfer_utility", "state: ${state}")
if (TransferState.COMPLETED == state) {
Log.d("transfer_utility", "completed")
Log.d("transfer_utility", "Bytes Transferrred: " + observerUtility?.getBytesTransferred());
Log.d("transfer_utility", "Bytes Total: " + observerUtility?.getBytesTotal());
val message = "Sent Message"
/*progressBar?.setVisibility(View.GONE)
spinner?.setVisibility(View.GONE)
spinner?.setClickable(false)
resumeOrPause.setVisibility(View.GONE)
thumbVideo.setClickable(true)
imageUpload.setVisibility(View.INVISIBLE)
editViewName.setFocusable(false)*/
//finishNotification()
var video = Video("SP_MOBILE_$fileName", null, bitmapdata, Uri.parse(mediaPath), Calendar.getInstance(Locale.getDefault()).timeInMillis)
daoUtils!!.save(video)
//Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
}
if (TransferState.PAUSED == state) {
Log.d("transfer_utility", "system pause paused_download: $paused_download")
//Log.d("transfer_utility", "verifying connection isOnline?: ${isOnline()}")
//if(!paused_download)
}
if (state == TransferState.FAILED) {
Log.d("transfer_utility", "Failed to Upload Image, Try Again.")
/*Toast.makeText(applicationContext,"Failed to Upload Image, Try Again.", Toast.LENGTH_SHORT);
val message = "Sent Message"
progressBar?.setVisibility(View.GONE)
spinner?.setVisibility(View.GONE)
spinner?.setClickable(false)
resumeOrPause.setVisibility(View.GONE)
thumbVideo.setClickable(true)
imageUpload.setVisibility(View.INVISIBLE)
editViewName.setFocusable(false)*/
//finishNotification()
}
if(state == TransferState.WAITING_FOR_NETWORK) {
Log.d("transfer_utility", "No Internet Access")
//Toast.makeText(applicationContext, "No Internet Access", Toast.LENGTH_LONG)
observerUtility!!.cleanTransferListener();
}
}
override fun onProgressChanged(id: Int, bytesCurrent: Long, bytesTotal: Long) {
val percentDonef = (bytesCurrent.toFloat() / bytesTotal.toFloat()) * 100;
Log.d("transfer_utility", "onProgressChanged percentDoneInt: ${percentDonef.toInt()}")
//publishProgress(percentDonef.toInt())
Log.d("transfer_utility", "bytesTotal: " + bytesTotal + " " + percentDonef.toInt() + "%");
Log.d("transfer_utility", "Processors: ${Runtime.getRuntime().availableProcessors()}")
Log.d("transfer_utility", "Max Memory in JVM: ${Runtime.getRuntime().maxMemory()}")
Log.d("transfer_utility", "Memory in Use: ${Runtime.getRuntime().totalMemory()}")
}
override fun onError(id: Int, ex: Exception) {
Log.e("transfer_utility", "error", ex)
/*val message = ex.localizedMessage
progressBar?.setVisibility(View.GONE)
spinner?.setVisibility(View.GONE)
spinner?.setClickable(false)
thumbVideo.setClickable(true)
imageUpload.setVisibility(View.VISIBLE)
editViewName.setFocusable(true)
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()*/
throw ex
}
})
now the logs:
04-07 16:35:42.093 6034-6034/com.robson.mandaaesportv I/TransferService: registering receiver
04-07 16:35:42.119 6034-6034/com.robson.mandaaesportv D/transfer_utility: state: IN_PROGRESS
04-07 16:35:48.805 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 0
bytesTotal: 80399106 0%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 4299518
04-07 16:35:53.955 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 1
bytesTotal: 80399106 1%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 5086879
04-07 16:35:54.973 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 2
bytesTotal: 80399106 2%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 5086879
04-07 16:35:58.424 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 3
bytesTotal: 80399106 3%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 5074382
04-07 16:36:05.344 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 5
bytesTotal: 80399106 5%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 5024095
04-07 16:36:08.044 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 6
04-07 16:36:08.045 6034-6034/com.robson.mandaaesportv D/transfer_utility: bytesTotal: 80399106 6%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 5024095
04-07 16:36:15.899 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 9
bytesTotal: 80399106 9%
04-07 16:36:15.900 6034-6034/com.robson.mandaaesportv D/transfer_utility: Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 4719391
04-07 16:36:19.232 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 10
bytesTotal: 80399106 10%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 5022816
04-07 16:36:24.224 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 11
bytesTotal: 80399106 11%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 4990704
04-07 16:36:27.662 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 13
bytesTotal: 80399106 13%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 5597119
04-07 16:36:30.373 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 14
bytesTotal: 80399106 14%
04-07 16:36:30.374 6034-6034/com.robson.mandaaesportv D/transfer_utility: Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 5597119
04-07 16:36:37.524 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 15
bytesTotal: 80399106 15%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 4992768
04-07 16:36:41.048 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 16
bytesTotal: 80399106 16%
Processors: 2
04-07 16:36:41.049 6034-6034/com.robson.mandaaesportv D/transfer_utility: Max Memory in JVM: 402653184
Memory in Use: 4992768
04-07 16:36:43.190 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 18
bytesTotal: 80399106 18%
04-07 16:36:43.191 6034-6034/com.robson.mandaaesportv D/transfer_utility: Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 5403024
04-07 16:36:47.557 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 19
bytesTotal: 80399106 19%
Processors: 2
04-07 16:36:47.558 6034-6034/com.robson.mandaaesportv D/transfer_utility: Max Memory in JVM: 402653184
Memory in Use: 4492238
04-07 16:36:50.458 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 19
04-07 16:36:50.459 6034-6034/com.robson.mandaaesportv D/transfer_utility: bytesTotal: 80399106 19%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 4492238
04-07 16:36:52.417 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 20
04-07 16:36:52.418 6034-6034/com.robson.mandaaesportv D/transfer_utility: bytesTotal: 80399106 20%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 6212527
04-07 16:36:52.417 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 20
04-07 16:36:52.418 6034-6034/com.robson.mandaaesportv D/transfer_utility: bytesTotal: 80399106 20%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 6212527
04-07 16:36:56.034 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 22
bytesTotal: 80399106 22%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 4545055
04-07 16:36:59.885 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 22
04-07 16:36:59.886 6034-6034/com.robson.mandaaesportv D/transfer_utility: bytesTotal: 80399106 22%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 4545055
04-07 16:37:06.072 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 24
bytesTotal: 80399106 24%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 5737471
...`
After 37% progress i put the app onBackground(onPause and onStop) with a physical button home in device virtual
`04-07 16:37:48.250 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 39
bytesTotal: 80399106 39%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 3648440
04-07 16:37:54.640 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 40
bytesTotal: 80399106 40%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 2995189
04-07 16:37:56.852 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 40
bytesTotal: 80399106 40%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 3573616
04-07 16:38:00.914 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 41
bytesTotal: 80399106 41%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 3176682
04-07 16:38:02.155 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 43
bytesTotal: 80399106 43%
Processors: 2
04-07 16:38:02.158 6034-6034/com.robson.mandaaesportv D/transfer_utility: Max Memory in JVM: 402653184
Memory in Use: 3220224
04-07 16:38:05.173 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 43
bytesTotal: 80399106 43%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 3065960
04-07 16:38:10.469 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 45
04-07 16:38:10.470 6034-6034/com.robson.mandaaesportv D/transfer_utility: bytesTotal: 80399106 45%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 3199669
04-07 16:38:15.681 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 46
bytesTotal: 80399106 46%
Processors: 2
Max Memory in JVM: 402653184
04-07 16:38:15.682 6034-6034/com.robson.mandaaesportv D/transfer_utility: Memory in Use: 3341664
04-07 16:38:24.972 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 49
bytesTotal: 80399106 49%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 3199530
04-07 16:38:26.655 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 50
bytesTotal: 80399106 50%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 3220704
04-07 16:38:29.730 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 52
bytesTotal: 80399106 52%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 2838357
04-07 16:38:36.000 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 53
bytesTotal: 80399106 53%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 3264298
04-07 16:38:42.802 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 54
bytesTotal: 80399106 54%
Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 3189824
04-07 16:38:43.911 1890-1927/system_process W/ActivityManager: Stopping service due to app idle: u0a91 -3m1s846ms com.robson.mandaaesportv/com.amazonaws.mobileconnectors.s3.transferutility.TransferService
04-07 16:38:43.916 6034-6034/com.robson.mandaaesportv I/TransferService: unregistering receiver
04-07 16:38:44.193 6034-6034/com.robson.mandaaesportv I/TransferService: Closing the database.
04-07 16:38:44.196 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged
percentDoneInt: 56
bytesTotal: 80399106 56%
04-07 16:38:44.197 6034-6034/com.robson.mandaaesportv D/transfer_utility: Processors: 2
Max Memory in JVM: 402653184
Memory in Use: 3263466
04-07 16:38:44.198 6034-6034/com.robson.mandaaesportv D/transfer_utility: state: PAUSED
04-07 16:38:45.268 6034-6034/com.robson.mandaaesportv D/transfer_utility: onProgressChanged percentDoneInt: 56
bytesTotal: 80399106 56%
Processors: 2
04-07 16:38:45.269 6034-6034/com.robson.mandaaesportv D/transfer_utility: Max Memory in JVM: 402653184
Memory in Use: 3263466
Sorry a big text, i try take the all information for you. These two processors may be two transfers?I just call one file.
Thank you @robsonn for posting the code snippet and logs. Few questions before we proceed.
1) Are you calling sendFileUpload from a background service or from an activity?
2) In onStateChanged callback when the state is WAITING_FOR_NETWORK, you are clearing the transfer listener attached with the observer. However you need not do this. When the network comes back, the TransferUtility automatically resumes the transfer. In that case your listener won't be called back because the listener is removed from tracking.
Thak you @kvasukib for reply again.
Actitiviy, extends AppCompatActivity(). I need a AsyncTask or Service or IntentService to use TransferUtility?
Thanks, i will remove it.
I has seen these samples: https://github.com/awslabs/aws-sdk-android-samples/blob/master/S3TransferUtilitySample/S3TransferUtilityTutorial.md
I will follow these informations and do the implematantion.
Thank you @robsonn for the quick reply. The sample code you posted should work from an Activity. There are limitations when you call sendFileUpload from a service in Android Oreo+. Can you remove the line: transferUtility!!.getTransfersWithType((TransferType.UPLOAD))? Since you are not capturing the return value of it. Can you try your app after removing this?
@kvasukib apparentely now its much faster than before, dont know if its because a fresh install or what, but i can see the speed on starting the upload.
another thing is that calling callAllWithType UPLOAD is working fast.
obs: when some files fail and another round the same file is uploaded in a new queue or the file is removed from the sdcard, the library will keep trying to upload and we get the timeout error
i mean, i think some checks like:
if file do not exists -> delete all awstransfer related to this file from table
if file exists and has more than one row about it on awstransfer table, keep one and remove others (i know that it keep the bytes count track)
make sense?
Thank you @defaultbr for the feedback. We are happy to hear that the upload initiation are faster now.
Regarding the checks, I am summarizing my understanding of the problem:
1) proposal: upload a file "file1.txt", if file is deleted during the course of operation, remove the transfer record pertaining to the file from the transfer database.
current state: we do the initial check before starting to upload the file for the existence of file but once we start the transfer we do not check the file again. so the thread which is actually operating on the file would throw an exception
2) proposal: multiple transfer records in transfer database, ensure there is one transfer record per file
current state: we do not check the database based on the file. Everytime you upload a file we create a new transfer record irrespective of the file object.
We will look into these proposals and post a reply here. Thank you!
@defaultbr
Apologies for the delay.
We have made some changes to TransferUtility in 2.7.0 version of the SDK. The summary of the changes can be found in CHANGELOG or Documentation.
Summary:
Starting version 2.7.0 of the SDK, TransferService logic has been refactored. This service now will be responsible only for monitoring network connectivity changes. When the network goes offline, the transfers that are in progress will be paused. When the network comes back online, the transfers that are paused will be resumed. If you expect your app to perform long-running transfers in the background, you need to initiate the transfers from a background service of your choice.
The TransferService will not be started or stopped by TransferUtility anymore. You have to start TransferService manually from your application. A recommended way is to start the service upon Application startup. One way you can do this is to include the following line in the onCreate method of your app's Application class.
getApplicationContext().startService(new Intent(getApplicationContext(), TransferService.class));
@defaultbr
Apologies for the delay.
We have made some changes to TransferUtility in 2.7.0 version of the SDK. The summary of the changes can be found in CHANGELOG or Documentation.
Summary:
Starting version 2.7.0 of the SDK, TransferService logic has been refactored. This service now will be responsible only for monitoring network connectivity changes. When the network goes offline, the transfers that are in progress will be paused. When the network comes back online, the transfers that are paused will be resumed. If you expect your app to perform long-running transfers in the background, you need to initiate the transfers from a background service of your choice.
The TransferService will not be started or stopped by TransferUtility anymore. You have to start TransferService manually from your application. A recommended way is to start the service upon Application startup. One way you can do this is to include the following line in the onCreate method of your app's Application class.
getApplicationContext().startService(new Intent(getApplicationContext(), TransferService.class));
Thanks @kvasukib.
I will test. Thanks again :D
Most helpful comment
Thank you @defaultbr for the feedback. We are happy to hear that the upload initiation are faster now.
Regarding the checks, I am summarizing my understanding of the problem:
1) proposal: upload a file "file1.txt", if file is deleted during the course of operation, remove the transfer record pertaining to the file from the transfer database.
current state: we do the initial check before starting to upload the file for the existence of file but once we start the transfer we do not check the file again. so the thread which is actually operating on the file would throw an exception
2) proposal: multiple transfer records in transfer database, ensure there is one transfer record per file
current state: we do not check the database based on the file. Everytime you upload a file we create a new transfer record irrespective of the file object.
We will look into these proposals and post a reply here. Thank you!