-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Issue 1218: cancelling ui thread tasks #1395
Issue 1218: cancelling ui thread tasks #1395
Conversation
…d into TestSampleRoboApplication_
|
This has merge conflicts. Can you rebase to develop? Could you squash the changes of the last two commits to the relevant previous commit(s)? These do not add any interesting info later in the history. |
9f75356 to
773a731
Compare
|
done 2015-05-05 0:00 GMT+03:00 Csaba Kozák notifications@github.com:
|
|
Thanks! You have one checkstyle violation. Please edit the commit which added that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some unnecessary lines here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
773a731 to
2726211
Compare
|
You have 6 Checkstyle violations. I am sorry, but i just realized what is the clean and Robolectric way of hacking the shadows=my.package.CustomShadowHandlerAfter that you can revert the modifications of the application class. Actually |
|
Should I restore commit history from the reflog and rebase changes again? |
If it is easier, yes. :)
The problem is with 3.0 that there is absolutely no ETA on that. We cannot depend on a Thanks! |
Do you have some easier options? :)
I understand, but it wasn't my primary intention. I mean, I think we should wait for Robolectric 3.0 with ANY suitable solution. If you insist, that own shadow is much better and cleaner - ok, will do the refactoring. But I don't think so. In my opinion there is no good solution here, so there is no point to waste time on this. |
|
I think nope. :) I think the own shadow is cleaner about the implementation. The hack is still there though after all, you are right. Also the current solution gets that field with reflection and sets the new anonymous class. The proposed solution does not have this perf impact. However, it effects all tests instead of just the Okay, you can leave it there, but maybe you should call the hack method in |
|
Ok, I'll do it in this way. |
|
Well, I failed to move commits through history. There are too much conflicts. |
|
@Artyomcool please do! |
2726211 to
244bb93
Compare
|
Done. Now it is right before all rebases, including actualizing develop. |
|
It was a pain to rebase this... It is here. Can you look at the commit diffs to check i did not kill anything accidentally? |
|
Good job! You only forgot to move robolectric hack into prepareTest, as you asked. I'm just wondering, how you managed to do this? Looks like you just rewrote every commit by hand. |
|
Thanks. I updated. I did not rewrite all commits by hand. 😄 Well, i soft reset the last commit, and created two commits of them: adding the hack in the right place, and moving the test to the package. Then i squashed these commits to the right commit in two rebase sessions to keep the number of conflicts as small as possible. Then i rebased the whole thing to develop. You are right, i edited all of the commits not just in the conflicts resolution, because i added formtting and removed Checkstyle errors, etc. But i would not say i rewrote them by hand. |
|
Well, where we are? |
|
I think it is ready to be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Artyomcool i almost forgot... I told you that we should run this in a try-finally block, so we make sure we remove the token even if the client code throws a RuntimeException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After you've got an exception here ui thread is effectively dead. Everything after that has no point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not agree. We store everything in static fields, so they are only cleared if the process is killed. If a RuntimeException happen in the ui thread, the Activity will likely crash, but it does not mean the process is killed. I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but you a not correct here. There is only one ui thread per process. When exception happens during looping, there is no way to restore it, even if you catch it in some way. Also, components never crash by themselves, only with a whole process. And it is very-very good thing, actually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to be sorry. :) You are right. I may have confused this with something
else, and just wrote down without really thinking it though.
I just tested this, and it goes up to ZygoteInit.main and dies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we could add some parameter to catch and log exceptions. Not sure if we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
i have one (hopefully last) comment. Can you please reset this branch to mine, then edit the "add: cleaning up the map at cost of synchronization" commit? |
|
Rebased and merged as of a9deed6. Thanks @Artyomcool for your great work on this! |
|
I updated the wiki. |
PR implements cancelling by using ids, like in background threads.