-
Notifications
You must be signed in to change notification settings - Fork 15
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
@Retained @Arg #15
Comments
Acknowledged, working on a fix. If I remember correctly, this should be as trivial as moving a bock of code. |
You can try the snapshot with:
The first sync will take about 5 minutes because it is built lazily |
@tom91136 Doesn't appear to be working. I believe you should be calling Activity.getIntent().removeExtra() as opposed to Activity.getIntent().getExtras().removeExtra(), as the latter creates a new copy of the extras each time. However, I still don't think that's going to fix things completely. There's no sort of |
Would it be more reliable to just swap the order things are restored in? #17 |
Good catch. I'm currently working a full rewrite of the library, so I'll make note of this and remember to have this bug fixed. You can probably see that code base is a complete mess right now, we got 3 abstractions for the As for the best way to solve this: I'm now stuck with two options:
Oh, and for the pull request: I would keep the statement: Both saves Akatsuki from restoring twice, but I'm not sure which approach is better. 1 seems logical but 2 looked faster. What do you think? |
Thanks for the reply. Very exciting to hear about the rewrite. I think this library has huge promise in terms of what it is attempting to solve and the performance-first methodology it's taking to solve it... but I'll admit that getting into the code and trying to understand thing didn't go so well 😀. I see what you mean by my oversight in that pull request. Something about adding a tombstone value I think feels wrong or lazy to me as well. One other option would be that after you apply the arguments, while you're restoring the bundle, instead of leaving the 2nd parameter of, for example |
Right now I'm doing some evaluation on how to handle "state" bundles and "arg" bundles. I figured that putting a Bundle in a bundle with a special key seems to be a good idea. (Bundle has a method called With this approach, we're limiting Akatsuki to work with it's own Bundle. This is good because we are far less likely to break other libraries by living in out own Bundle "namespace" (reduced key collisions). It goes like this(restore):
Any thoughts or suggestions? |
How would @arg entries get in? Would they still be (whether they're individual or part of a bundle) part of the intent? The only thing I'm still slightly concerned with is that I get the feeling getIntent() is expected to be immutable... or, at very least, that the APIs for interacting with an intent seem inconsistent on whether they truly alter the incoming intent or simply a copy of it. |
That was what I was hoping, I imagine there will be security concerns if it was mutable. I did some digging and from what I see, it seems that Personally, I think the whole state persistence mechanism in Android is extremely poorly documented and awkward to use. But after all, the goal for my library is to fix this situation, so yeah, at least future Android developers does't have to worry about this. I could be blind and did't read the docs carefully enough to understand what's happening. In that case, please point me in the right direction. |
No, I think you're 100% right about everything there (including how messy the implementation is 😠 ), my only thought was to consider whether you're planning on abusing an "undocumented" feature that could easily change in the underlying source code. Having re-read the documents... I don't think you are and I personally haven't seen many (or any that come to mind) examples of Android projects suffering regressions due to "fixes" in the underlying AOSP. If I'm to think optimistically, I think your plan sounds completely fair and is the most performant option. If I'm to think pessimistically, I think that we should flip the flow to be;
|
Just spotted https://github.com/workarounds/bundler which seems to have a very similar scope. Their "solution" to this problem is what we were discussing earlier... letting the restoration happen twice, which, yes, is wasteful, but ensures the behaviour you'd expect. |
I would say the scope is identical :). Looks like a good library, but unit tests are missing. I hope the author finds time to add some unit tests as the scope is relatively complex. Since I'm currently doing computer science in university, I like challenges; I'm more towards creating a reusable framework for annotation processing and code generation. (Justified after reviewing the current codebase). Now, I did do some research on annotation processing before I started this project. It seems that support is very limited. We don't have a proper testing framework for all the To solve to two problems above, I wrote two other libraries:
I hope this gives you an idea on what I'm working on right now and where I'm headed (and maybe justify the long wait since 0.2.0). You can probably see that I'm enjoying the development process more than actually having the end product ready in a timely fashion. Sorry for this long blab, I guess I just need to write this down somewhere. As for the real question about restoration: I'll do some testing on whether the penalty of restorating twice is actually great enough to switch to my nested bundle implementation. I'll let you know when the rewrite is done. In the meantime, suggestions are welcomed. (especially for the code generation idea mentioned above in point 1) |
@retained @arg is not working as expected. As I understand, argument must be restored into variable only when savedInstanceState is null. Otherwise it will always overwrite retained value. Retained value must have higher priority over argument, except first time activity/fragment is created.
P.S. Thanks for great library.
The text was updated successfully, but these errors were encountered: