Giter Site home page Giter Site logo

Comments (8)

openaphid avatar openaphid commented on August 25, 2024

FlipViewController.sideBufferSize is designed to control the number of preloaded pages. The default value is 1, which means 1 previous page, the current page and 1 next page are loaded after flipping to a page.

Unfortunately in your scenario, the lazily loaded content may not be visible during animation as the screenshot of the page was took before they're ready.

I think we may need an API to notify FlipViewController to update the screenshot on demand.

from android-flip.

quintos avatar quintos commented on August 25, 2024

Indeed.

Do you think you can make it re-use Bitmaps?

from android-flip.

openaphid avatar openaphid commented on August 25, 2024

@murimons I implemented a rough solution. The key idea is to use FlipViewController.refreshPage(View pageView) to make the animation reload content of an updated page.

The codes are developed in a new branch: feature/api-content-update

Please let me know if it meets your requirement. I'll merge it back to the main branch later

from android-flip.

openaphid avatar openaphid commented on August 25, 2024

Two new methods are added to support refreshing a page manually:
FlipViewController.refreshPage(View pageView)
FlipViewController.refreshPage(int pageIndex)

from android-flip.

quintos avatar quintos commented on August 25, 2024

Excelent!

This meets my requirement indeed!

question:

In the docs you say that for an active page this would be an expensive operation. Do you mean a page that is being viewed at that moment or flipped? So when i flip to a page which is still in the middle of lazy loading my image and when that finishes (and i'm still looking at it) , i refresh the screenshot, this would be a heavy operation? in terms of memory?

thanks!

from android-flip.

openaphid avatar openaphid commented on August 25, 2024

An active page is the one of which content is involved in animation. You can treat the current page and its next one be the active pages as both of them are needed to render the animation.

The refreshing routine is no more heavier than manually flipping page. It triggers the following operations for the active pages:

  1. Makes the page draw in a bitmap in the UI thread to get a screenshot. (The memory consumed is corresponding to the size of the page, but normally it would be fine and it doesn't trigger large GC pause as bitmap doesn't store data in VM heap.)
  2. Binds the bitmap to an OpenGL texture in GL thread, and recycles it.

The first step is "heavy" as it asks the page to re-draw itself, which could be a bit slow for a very complex view hierarchy.

My suggestion in the doc is a note for the potential cost. For example, if you are rendering a view animation in a page, then it better not to call refreshPage() for each frame of the animation.

from android-flip.

quintos avatar quintos commented on August 25, 2024

I understood that It doesn't store pixels in the heap but the Bitmap memory does get accounted against the heap. So if a refresh allocates a native Bitmap it also uses up the memory in the Java heap. But GC could still be fast because the Bitmap object in the heap is small. (Is GC speed related to object size?)

I'm still having issues with Bitmaps in my app causing OOM exceptions because of this (Not related to android-flip). I'm now trying to find a way to re-use Bitmap objects.

from android-flip.

openaphid avatar openaphid commented on August 25, 2024

The native memory occupied by bitmap instances can lead to OOM as the VM budget is constrained by the sum of heap memory and native memory.

Please check out gclog.py if you want to check the real memory usage of your app.

from android-flip.

Related Issues (20)

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.