Giter Club home page Giter Club logo

Comments (4)

artem-zinnatullin avatar artem-zinnatullin commented on July 23, 2024

Right now Domic renders everything by posting to Choreographer at constant time intervals.

Changes posted to Domic's DOM do skip current frame and are rendered on the next frame which is not a problem in general since data arrives asynchronously in the first place but it falls into "First frame problem" case.

Possible solution:

Expose an API to force rendering of the current buffer ie Renderer.renderCurrentBuffer() (naming is not final).

Default Renderer implementation, AndroidRenderer will render current buffer synchronously if renderCurrentBuffer() was called on main thread (throw exception if called on non main thread?).

Call to this method can be integrated into userland code or frameworks like Scoop, Fragments, Activity, etc to render current buffer when first lifecycle method finishes thus giving user a way to solve "First frame problem"

ie:

class MyActivity : Activity {

    override fun onCreate(…) {
        setContentView(R.layout.myactivity)

        // Bind Domic, push some changes to render.

        renderer.renderCurrentBuffer()
    }

}

We could do some heuristics inside Domic to make it automatic, but that doesn't look scalable and flexible enough to be able to integrate with different frameworks like Scoop.

from domic.

artem-zinnatullin avatar artem-zinnatullin commented on July 23, 2024

Please note that lots of apps already skip first frame due to observeOn(mainThread) applied everywhere before interaction with the view layer which posts to Handler thus skipping current frame

See also:

Solving this problem is not the goal of Domic's existence, but looks like we can do something about it in more controllable way than RxAndroid or RxBinding can since we have rendering pipeline with buffering.

from domic.

Dimezis avatar Dimezis commented on July 23, 2024

I'm not sure that something like renderer.renderCurrentBuffer() will work. Given your data sources are asynchronous and emitting from different threads, you might just not have all the data needed to render in Activity's onCreate.
So first of all, data sources have to have a cached data and emit it synchronously on subscription, but I suppose that kinda contradicts to Domic's idea.

from domic.

artem-zinnatullin avatar artem-zinnatullin commented on July 23, 2024

@Dimezis we obviously can't solve async data problem in Domic on general sense, that's not a goal and as you noted Domic is actually async-only by design

However, often times even in async systems data is cached in memory and is effectively accessed synchronously! Unless there are enforced thread jumps.

For example just yesterday @kxfang measured that about 66% of data in golden path of our app comes from memory but due to observeOn(mainThread) we're still skipping first frame.

I linked issues from other Rx projects because it's a known problem in async/reactive systems and there are cases when, yes, you're writing async code but it actually gets synchronously executed.

This API won't solve problem of async data arrival but it'll help get the first frame for data cached in memory which is not bad right :)

We won't be promoting it as "The Solution" but rather like "We did what we could on our side and gave you the tools, now it's up to you :)"

from domic.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.