flow icon indicating copy to clipboard operation
flow copied to clipboard

New way to break Flow.goBack()

Open dcow opened this issue 7 years ago • 3 comments

I have encountered an issue where the history size shrinks while a traversal is in-flight. This could happen any time you hold traversals while you're switching screens (perhaps for an animation) and mash the back button quickly. It appears the issue is noted:

https://github.com/square/flow/commit/8a9325bc89118d3f6704e4e65f13231bf4efc407#diff-0351f5577272525804cf0292acb7fe1bR283

#195 #240

but I don't think the solution of simply noop-ing the traversal is entirely correct. When this happens, the dispatcher never gets to execute the next pending traversal. It may be a good idea to noop the traversal, but the dispatcher still needs to flush traversals so that the whole thing doesn't grind to a halt. Another option might be to continue dispatching the traversals but not pop the history if Flow notices the history has changed size.

A workaround is to not hold onto traversals, but that's not really what you want to do long term.

dcow avatar Jun 13 '17 02:06 dcow

So I'm guessing the problem is that it does a return; and not an immediate onTraversalCompleted() (which wouldn't work because it's not technically "dispatched"), and therefore somehow you can enqueue ops after the enqueued goBack() but it is not started because of return; instead of starting the next enqueued traversal if possible?

https://github.com/square/flow/blob/2982c5eb26fdc2b93e1d9b20f242c062ad73edb5/flow/src/main/java/flow/Flow.java#L331-L341

Zhuinden avatar Jun 17 '17 00:06 Zhuinden

Have you figured out if my hunch was right or wrong? I mean, I haven't used Flow in a while.

Zhuinden avatar Jul 11 '17 21:07 Zhuinden

@dcow here how I solved the issue for me https://github.com/sdelaysam/flow/commit/4980cefd298fc33068fa155801f6423b89a0a57f

sdelaysam avatar Sep 12 '17 16:09 sdelaysam