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

[Bug]: Android在内存重启时,无法正常恢复页面堆栈 #2133

Open
joechan-cq opened this issue Sep 10, 2024 · 1 comment
Open

Comments

@joechan-cq
Copy link
Collaborator

请描述遇到的问题,以及您所期望的正确的结果

如果全都以withContainer=true的方式打开新页面,在内存重启后,操作push、pop,看起来页面堆栈是正常的,但其实并没有真的恢复。
内存重启后,app回到前台,顶层的FlutterBoostActivity重建后,Flutter页面恢复,此时FlutterBoost的堆栈管理中只存在当前这一个页面,并没有前面页面的堆栈记录。如果往前返回,看似能够回到上个Flutter页面,但其实是上个FlutterBoostActivity重建,然后根据Native的Intent中的数据进行了重新加载。此时的FlutterBoost中记录的堆栈,仍然只剩当前这个页面。

请说明如何操作会遇到上述问题

No response

在下面填入关键复现代码

复现的平台

Android

Flutter SDK版本

3.22.2

FlutterBoost版本

dev/exp

是否延迟初始化FlutterBoost

No

解决方案

@joechan-cq
Copy link
Collaborator Author

flutter_boost_app.dart中有用于hotrestart恢复堆栈的_saveStackForHotRestart_restoreStackForHotRestart方法。只是对应到Native中也只是以内存变量方式存储。
image

可以将_saveStackForHotRestart传下的dartStackonSaveInstanceState时进行序列化存储,然后在onCreate时恢复并设置这个dartStack,这样Flutter层就能靠_restoreStackForHotRestart进行页面堆栈的恢复。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant