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

java.lang.IllegalStateException: There is no read or rewind or length check in progress CronetUploadDataStream #12

Open
yangjiantao opened this issue Dec 20, 2022 · 5 comments
Labels
bug Something isn't working input-needed Blocked on input from the reporter

Comments

@yangjiantao
Copy link

yangjiantao commented Dec 20, 2022

crashes are counted on firebase.

my UploadDataProvider code:

        @Override
        public void rewind(UploadDataSink uploadDataSink) {
          if (LogUtils.isLogEnable()) {
            LogUtils.d("cronet", "InMemoryRequestBodyConverter , rewind: "+requestBody.isOneShot());
          }
          if (requestBody.isOneShot()) {
            uploadDataSink.onRewindError(new UnsupportedOperationException("Rewind is not supported!"));
          }else{
            isMaterialized = false;
            materializedBody.clear();
            uploadDataSink.onRewindSucceeded();
          }
        }
@Danstahrg
Copy link
Contributor

Can you please provide the full stacktrace?

@Danstahrg Danstahrg added bug Something isn't working input-needed Blocked on input from the reporter labels Dec 20, 2022
@yangjiantao
Copy link
Author

yangjiantao commented Dec 20, 2022

just occurs in custom uploadExecutors

Fatal Exception: java.lang.IllegalStateException: There is no read or rewind or length check in progress.
at org.chromium.net.impl.CronetUploadDataStream.b(:com.google.android.gms.dynamite_cronetdynamite@[email protected] (170306-0):6)
at eq.run(:com.google.android.gms.dynamite_cronetdynamite@[email protected] (170306-0):6)
at com.cname.core.threadpool.lib.CommandThreadPoolExecutor.runWorker(:54)
at com.cname.core.threadpool.lib.Worker.run(:2)
at java.lang.Thread.run(Thread.java:923)
at com.cname.core.threadpool.lib.CommandThreadFactory$1.run(:9)

aarongable pushed a commit to chromium/chromium that referenced this issue Dec 20, 2022
… called outside of user callback context.

Knowing what caused the onError method to be called significantly simplifies troubleshooting (e.g. google/cronet-transport-for-okhttp#12) 

Change-Id: Ic0718d39e2eb68ac96f821f28ca8bc0baab3fec5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4110976
Reviewed-by: Stefano Duo <[email protected]>
Commit-Queue: Dan Stahr <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1085385}
@yangjiantao
Copy link
Author

@Danstahrg I'm confused, can this modification avoid this crash? The exception is still thrown and not caught [疑问]

if (mInWhichUserCallback == UserCallback.NOT_IN_CALLBACK) { throw new IllegalStateException( "There is no read or rewind or length check in progress.", exception); }

@Danstahrg
Copy link
Contributor

You're right in that it doesn't solve your issue straight away but as noted in the commit description it allows for more efficient troubleshooting.

If you look through the code in more detail you'll find out that the onError method that throws the exception is only called from other methods which either check mInWhichUserCallback value or set it it themselves. As this occurs within onError method the exception you're seeing is just a symptom of another problem, and seeing the exception that caused it in the first place would help us zoom in in more detail.

As to what the actual problem is, given the above this looks like multiple callback methods being executed concurrently and interfering with each other. It looks like you're using a custom upload data provider - are you reusing instances of it by any chance?

Either way, this looks like an issue unrelated to this shim library - can you open a Chromium bug? Please include the full implementation of your data provider and examples of how you use it.

@yangjiantao
Copy link
Author

I used this library, only modified here
image

the usage is the same as okhttp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working input-needed Blocked on input from the reporter
Projects
None yet
Development

No branches or pull requests

2 participants