FluidFramework icon indicating copy to clipboard operation
FluidFramework copied to clipboard

Promote dirty document signal to loader/runtime

Open ruchika-m opened this issue 6 years ago • 10 comments

Feature

With the recent data loss issues we observed, there was an ask to make use of the dirtyDocument signal that exists today in runtime to prompt users when exiting a page that has changes that haven't been pushed through. However the signal isn't a high level property that everybody can access. The Preview app does some hacky stuff like so,

(container as any).context.runtime.dirtyDocument

Describe the solution you'd like Instead of trying to access the signal as the app does today(which is also not suitable for other UI hosts when they plan to implement similar behavior) on the container.context.runtime, can we promote the signal to a layer that the host apps have direct access to?

ruchika-m avatar Apr 21 '20 21:04 ruchika-m

Similar issue tracking this ask: https://github.com/microsoft/FluidFramework/issues/1279

sureshsitaula-personal avatar Apr 22 '20 18:04 sureshsitaula-personal

Belongs to FCL.

vladsud avatar Jul 30 '20 02:07 vladsud

Pinging this! We'll need this support (as well as support for dirty/saved events) in order for the hosts to detect when data loss is possible as well as when the container becomes clean and thus safe to destroy. @vladsud

aboktor avatar Sep 02 '20 00:09 aboktor

There is currently no plan to expose it in Fluid framework. Mostly because this notion is not universal (consider games built using Fluid). Container layer does not manager that space, i.e. all the logic around pending ops (and notion of pending ops) is part of ContainerRuntime (i.e. particular implementation). And as you likely know, even that is problematic (we do not have clean way to separate user driven changes vs. system ops, like scheduler ops - we do trivial filtering, but it's rudimentary and does not scale).

Correct way to implement is it to have an proper interface and query it object (implementing this interface) by host from container. If container does not implement it, then host needs to have some default behavior. "Document" oriented containers can leverage common implementation in this space - this makes sense to be in "component" world, but not in Fluid framework.

Thus I believe the right things are

  1. close this item,
  2. continue to iterate in the app (but in a proper way, i.e. not rely on casting and reaching out to runtime, but use queries and proper interfaces / feature detection)
  3. Eventually move it to shared "component" repo.

Please let me know what you think.

vladsud avatar Sep 02 '20 06:09 vladsud

How would a container implement this?

leeviana avatar Sep 02 '20 23:09 leeviana

Same way as you implement any other components in container. The only missing piece is convention - how host can get to it. I think it should be abstracted away via some helper function, that would hard code uri path in "document type" container to get to such object.

vladsud avatar Sep 03 '20 00:09 vladsud

I think we're moving towards typesafe rootcomponent IFluidObject conventions for container APIs. But I'm not sure how we would get the information about dirty vs non dirty in component code. What do we have access to that gives us this information?

leeviana avatar Sep 03 '20 00:09 leeviana

I think we're moving towards typesafe rootcomponent IFluidObject conventions for container APIs. But I'm not sure how we would get the information about dirty vs non dirty in component code. What do we have access to that gives us this information?

ContainerRuntime has an 'isDocumentDirty'

aboktor avatar Sep 03 '20 17:09 aboktor

Ah great, so we can just expose this as an API on root component for hosts to consume properly right now, does that sound good? :D

leeviana avatar Sep 03 '20 19:09 leeviana

I really think we need to reevalute this request. We're getting requests from partner container experiences/hosts to read this flag in a generic way and I don't think it's sustainable - or a good contract - to tell everyone they need to architect their containers in such a way to always return a container API with a manually implemented dirty contract (which is difficult because components don't have access to the containerRuntime) on '/' and that all hosts have to request both the component and the separate top level container API component to use alongside ExternalContainer.ts in order to do a dirty feature detection on '/'. And if it doesn't exist then user's lose ops.

@vladsud when you mention different scenarios/needs for this API, I think it's a host decision what to do with documentDirty, not a container/component decision. And hosts fully expect this on top level container API. Whether they use the flag or not is up to them but having every container try to manually manage this containerRuntime relationship is a nightmare so far.

leeviana avatar Sep 22 '20 19:09 leeviana