xamarin.flutter icon indicating copy to clipboard operation
xamarin.flutter copied to clipboard

Client/Server architecture for stateful hot reload

Open JeroMiya opened this issue 7 years ago • 6 comments

So obviously this isn't the highest priority for version 1 given that the transpiler isn't complete, but I thought I'd bring it up in case planning for this feature might affect design decisions going forward.

Basically, state-full hot reload would be implemented using a client/server architecture whereby a server on the development machine watches for file changes and sends updates to the running flutter engine, which then dynamically recompiles views on the fly, preserving state.

This is similar to how livexaml and HotReload work. The tricky bit is dynamically recompiling views, given that they are now C# code and not xaml files. Perhaps in debug mode the whole app runs in interpreted mode and gets live reloaded? Can we use the mono interpreter?

JeroMiya avatar Dec 28 '18 14:12 JeroMiya

The Xamarin team work on this feature.

mohachouch avatar Dec 28 '18 16:12 mohachouch

@mohachouch I wasn't aware (do you have a link with details?) though I suspect what they are implementing is either full app reload at the assembly level or hot reload of XAML only, or both. For us, we could take advantage of any assembly hot reload functionality they might have, but we'll still need to implement something ourselves if we want a stateful hot reload.

JeroMiya avatar Dec 31 '18 17:12 JeroMiya

It’s a tweet from Miguel De Icaza https://twitter.com/migueldeicaza/status/1076488386439974912

mohachouch avatar Dec 31 '18 20:12 mohachouch

Implementing by ourselves would be a gigantic, if not impossible, effort. It's not just on client side, it's also tooling. What they are doing is using an interpreter (which Mono recently got) and integrating that into IDE and debugger (hopefully both).

MihaMarkic avatar Jan 02 '19 17:01 MihaMarkic

@MihaMarkic I realize stateful hot reload can't be a priority for this stage of development, but difficult or not on a technical level, stateful hot reload is a hard requirement. It is THE top feature of Flutter and probably why most Flutter developers started using it. Perhaps not at the level of support available in Flutter, which would require VM level support for hot code reloads with preserved state (and detection of incompatible changes), but perhaps by storing the "state" of the app in a serializeable form that can survive a full hot reload of the entire app assembly?

JeroMiya avatar Jan 03 '19 17:01 JeroMiya

@JeroMiya While that might be achievable, the debugger and IDE support is not.

MihaMarkic avatar Jan 03 '19 19:01 MihaMarkic