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

Aws S3 StrictMode policy violation #603

Closed
niqo01 opened this issue Dec 7, 2018 · 6 comments
Closed

Aws S3 StrictMode policy violation #603

niqo01 opened this issue Dec 7, 2018 · 6 comments
Assignees
Labels
bug Something isn't working s3 Issues with the AWS Android SDK for Simple Storage Service (S3).

Comments

@niqo01
Copy link

niqo01 commented Dec 7, 2018

Describe the bug
The AWS S3 SDK is doing IO operation on the main thread which is reported by strict mode

To Reproduce
Steps to reproduce the behavior:

  1. Use the S3 SDK
    'client': "com.amazonaws:aws-android-sdk-mobile-client:2.8.5",
    's3': "com.amazonaws:aws-android-sdk-s3:2.8.5"
  2. Enable Strict mode
  3. Upload successfully a file
  4. Check logcat
  5. See warning:
StrictMode: StrictMode policy violation; ~duration=9 ms: android.os.StrictMode$StrictModeDiskWriteViolation: policy=65599 violation=1
        at android.os.StrictMode$AndroidBlockGuardPolicy.onWriteToDisk(StrictMode.java:1386)
        at android.database.sqlite.SQLiteConnection.applyBlockGuardPolicy(SQLiteConnection.java:1044)
        at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:732)
        at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
        at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
        at android.database.sqlite.SQLiteDatabase.delete(SQLiteDatabase.java:1576)
        at com.amazonaws.mobileconnectors.s3.transferutility.TransferDBBase.delete(TransferDBBase.java:226)
        at com.amazonaws.mobileconnectors.s3.transferutility.TransferDBUtil.deleteTransferRecords(TransferDBUtil.java:517)
        at com.amazonaws.mobileconnectors.s3.transferutility.TransferStatusUpdater.removeTransferRecordFromDB(TransferStatusUpdater.java:155)
        at com.amazonaws.mobileconnectors.s3.transferutility.TransferStatusUpdater$1.run(TransferStatusUpdater.java:220)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Which AWS service(s) are affected?
Aws S3 SDK
Expected behavior
No warning using strictmode

Screenshots
If applicable, add screenshots to help explain your problem.

Environment(please complete the following information):

  • SDK Version:
    'client': "com.amazonaws:aws-android-sdk-mobile-client:2.8.5",
    's3': "com.amazonaws:aws-android-sdk-s3:2.8.5"
@rohandubal rohandubal added the s3 Issues with the AWS Android SDK for Simple Storage Service (S3). label Dec 10, 2018
@rohandubal
Copy link
Contributor

Hello @niqo01

Thanks for reporting this issue. We will look into this.

Thanks,
Rohan

@rohandubal
Copy link
Contributor

Hello @niqo01

Is it possible to provide a code snippet of how you are using the S3 library in your application? In the SDK we try to not create extra threads and use the ones which are available.

Thanks,
Rohan

@mutablealligator
Copy link
Contributor

@niqo01 Sorry for the delayed response. TransferStatusUpdater has the methods to update the state and progress and notify the customer's callback (TransferListener) of the state and progress updates.

The following code from updateState method invokes the onStateChanged callback by running on the main thread. We do this in order to invoke the TransferListener callback.

 // invoke on main thread
        mainHandler.post(new Runnable() {
            @Override
            public void run() {
                for (final TransferListener l : list) {
                    l.onStateChanged(id, newState);
                }
                // remove all LISTENERS when the transfer is in a final state so
                // as to release resources ASAP.
                if (TransferState.COMPLETED.equals(newState)
                        || TransferState.FAILED.equals(newState)
                        || TransferState.CANCELED.equals(newState)) {
                    list.clear();
                }
                
                if (TransferState.COMPLETED.equals(newState)) {
                    removeTransferRecordFromDB(id);
                }
            }
        });

However as you pointed out, we are doing a disk operation to remove the transfer record from the database in the main handler. I am working on to move this disk operation outside the main thread. Will post an update once the fix is made.

Thank you for bringing this to our attention.

@frankmuellr frankmuellr added bug Something isn't working pending-release Code has been merged but pending release and removed enhancement labels Dec 28, 2018
@mutablealligator
Copy link
Contributor

@niqo01 This issue has been fixed in the version 2.9.2. Please upgrade and let us know any feedback you have. Thank you!

@frankmuellr frankmuellr added pending-community-response Issue is pending response from the issue requestor and removed pending-release Code has been merged but pending release labels Jan 2, 2019
@mutablealligator mutablealligator added closing soon Issue will auto-close if there is no additional activity within 7 days. and removed pending-community-response Issue is pending response from the issue requestor labels Jan 4, 2019
@stale stale bot removed the closing soon Issue will auto-close if there is no additional activity within 7 days. label Jan 4, 2019
@mutablealligator
Copy link
Contributor

mutablealligator commented Jan 10, 2019

Closing this issue as there is no activity and the bug fix is released. Please open a new issue if you are still encountering problems.

@mutablealligator
Copy link
Contributor

Thank you for pointing this issue. We have fixed it. If you still encounter a new problem in the latest SDK, please feel free to open a new issue,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working s3 Issues with the AWS Android SDK for Simple Storage Service (S3).
Projects
None yet
Development

No branches or pull requests

4 participants