Closed yvone1991 closed 6 years ago
I spent a lot of time trying to recreate your application but you omitted a lot of things. Please provide a standalone application, preferably a GitHub project, that compiles and demonstrates your problem.
Also provide a clear indication in between which points in your application do you experience that 2 minute delay. Please run your application in debug mode and pause it to see which thread does what that could hint about the source of the delay.
I also recommend starting over with your application, step-by-step, and see what change introduces that huge delay, if any.
Logger.d("new Ob duration======>" + (newObCallbackTime - newObStartTime));
sometimes the duration more than 2 min~~~~sometimes..sometimes...sometimes...
【code】
private void testNewOb() {
newObStartTime = SystemClock.currentThreadTimeMillis();
Logger.d("new Ob create time on======>" + newObStartTime);
Observable observable = Observable.create(new ObservableOnSubscribe
//todo refreshView();
}
});
}
Please use the triple backtick to denote code. Check out your question's sources which I fixed for you.
I can't see any reason for that large delay. Maybe your device has a particular runtime where class initialization takes really long. Try with a very basic project and that code part only that measures the time to create body.
At first, when I wrote the UI interface, there was no such problem. (maybe I didn't test too many times.)
When I write request logic on each interface, the create side will start waiting for a long time to start the launch(sometimes...sometimes...sometimes).
I try to write a base project, but I can't guarantee that it will happen. And my whole project itself is just like my example code, and there's no extra thing to add, but I don't know why there's such a big delay when it's created.
whole project logic:
【Every activity goes like this】 Activity→bindLayout→findViewById→createObservable(delay more than 2 min, sometimes)→loadData( two minutes later, start this method )→onYourThings→createNewObservable(sometimes,delay more than 2 min)....
Without the entire project, I can't help you much further. Does it happen inside an emulator or on a device? Could you post your entire project on your GiHub repository?
Can I send your e-mail?
-----my project(^_^)
Yes. The address is my github handle + gmail.com
Your email is classified as spam by the service provider (akarnokd@gmail.com), and the other party will not accept it.
I can't give you any other email address. Are you on Twitter? Upload your code somewhere and PM me the URL.
I sent you with my company mailbox. Did you recieve it?
There is no attachment or link.
In one of your emails, you mentioned this delay happens on POS devices. It could be device/Android specific anomaly. Are you using ProGuard? If not, try it; if yes, disable it and see if that helps.
I try it again,Did you recieve it?
I received a letter which asked me to ask for Google Drive permission of two files.
yes
pen***555+gmail.com
I've already asked for permissions.
I have shared files
I've downloaded the project and built it. Where is the code that takes too long?
OrderMenuActivity.class AddOrderActivity.class OrderStatusActivity.class OrderSureActivity.class TableAvtivity.class
1、sometimes,onYourThings() delay 2 min reach。。。 2、I have annotated a method: HttpManager.java line106 to line 110 log... ====>
/**
* 请求前的准备
*/
private Observable readyRequest(final String method, final Object body) {
Logger.d("这里开始开始发送数据源===========>readyRequest()" + DateUtils.getNowDate(DateUtils.FXGALL));
Observable observable = Observable.just(body).map(new Function<Object, HttpRequest>() {
@Override
public HttpRequest apply(Object o) throws Exception {
Logger.d("这里开始组包===========>" + DateUtils.getNowDate(DateUtils.FXGALL));
HttpRequest request = new HttpRequest();
request.setMethod(method);
request.setTimestamp(DateUtils.getNowDate(DateUtils.FXGALL));
request.setBiz_content(body);
request.setMac("222");
request.setSession_id("222");
Logger.d("这里组包完毕,发出去给retrofit2了===========>");
return request;
}
}).subscribeOn(Schedulers.io());
All Observable that needs to be created may be delayed. The previous use of rxjava1 did not have this problem
That readyRequest
seems to be not in use. Are you sure you match the time difference properly in your log?
It was originally used, and later removed。。。
line159 to line 327,I have annotated them……
Finally, I found that the problem of rxjava2 creation is not a create operator problem.
It was originally used, and later removed。。。
How would you expect me to diagnose your problem when the code isn't the one exhibiting the problem?
Finally, I found that the problem of rxjava2 creation is not a create operator problem.
It is likely you have a flaky network so it takes sometimes longer to get all response.
Thank you very much for your patience.
At first I also suspected that it was a network problem, or something else, but until I used that way to verify it, I found that the time for creating OB was delay for a very long time.
But the problem I'm describing is that all the annotations I've done are to prove that something went wrong when I created the OB. Personally, I think the key to the problem is to delay when creating OB objects. Because after 2min is delayed, all log will be brushed out in a flash, rather than a normal brush.
【version】
【question】 I integrate rxjava2 operations in the parent class of activity, but sometimes the operator has to wait a long time to get into the method. Is it caused by rxjava2? Using rxjava1 does not appear to be a problem...
【question-ex】
---------Sometimes the duration will more than 2 min!!!!!!!!!!!!!!!!!!!!!!!!!!!!-------
【code-BaseActivity】
【code-BaseView】
【code-MyViewClickObservable】
【code-RxClickListener】