How to fix" Website loading issues" Magenot2? - magento2

Consider lazy-loading offscreen and hidden images after all critical resources have finished loading to lower time to interactive.

Related

Bug: ion-spinner has memory leak

Platform: All(Android/ios/Windows etc..)
Problem 1:
The current implementation does not cleanup on the deletion of the scope. This leads to a memory leak. The spinning animation keeps on running even if the spinner is not in the dom anymore. The animation should be stopped when the scope gets destroyed. This degrades scrolling performance too.
Once they have been displayed and then hidden again they still remain in the DOM animating and eat up CPU. After a while on Android devices it heats the phone up and runs the battery down very quickly, especially if you have loaded the animated SVG in multiple views / places while using the app.
Problem 2:
The spinner in combination with the infinite-scroll directive.
It is not sufficient to have the spinner translated out of view. (Why this solution was chosen instead of opacity?). The spinner is still getting animated and degrades scrolling performance on iOS devices a lot. Even if out of view.
I simply replaced the SVG spinner with a .gif loader:
$ionicLoading.show({
template: "<span class='loader'></span>"
});
Not the best solution but at least it works.

How to get rid of the hitch when lazy loading pages of a UIScrollView

I tried to implement the lazy loading solution for UIScrollView with paging enabled, as in the PageControl example from Apple. It seems to work fine, the only problem is that as the user scrolls past the 50% of the page, there is this short hitch as the content of the next page is loaded (obviously because loading the next ViewController takes some time and it seems to happen on the main thread).
Is there some way to make the scrolling seem more smooth that would work no matter how fast the user scrolls ?
You need to make sure that anything which takes time happens asynchronously. The techniques for this will vary based on what kind of content you're loading or what sort of drawing you're doing that causes the delays. Try to load images in the background, do custom drawing in the background, use operations or gcd to break up large tasks into smaller chunks that can happen concurrently, etc.
You should be lazy loading the surrounding pages so that they're already loaded when the user scrolls.
So if the user scrolls to page 2, load pages 1 and 3 (if they aren't already)

Do hidden animated GIFs still use the CPU?

I have an AJAX heavy website. There's hundreds of buttons that momentarily put up an animated loading GIF when the server is processing a request.
I noticed that my site is sluggish after using it for several minutes. The animated GIFs play at lower framerate. They sometimes even stop animating. Hover effects on buttons have a noticeable lag. Is it possible that these hundred animated GIFs are still locking up the CPU even while they're hidden (style="display: none")? At most, only a few GIFs are visible at any point in time.
Things that are hidden using style-sheets still exist in, and are resolved by the browser (and can therefore be manipulated by script), they are just not displayed to the user.
This is in contrast to when controls are marked as .visible=false in which case they are not marked up in the browser (and therefore cannot by manipulated by script)

Load an OpenGl view in the background. iPhone

I have an OpenGL view that renders a 3D model. It is a basic modification on Apples EAGLView. This view is added to a controller's .view and displayed with presentModalViewController: . I would like to do all of the model loading, and OpenGL state configuration in a background thread at app launch before the user chooses to display the view. Is this possible? Can I load textures, setup lighting, and generally just get everything ready to render in a background thread? My fear is that the Cocoa touch portions of the app on the main are going to manipulate the OpenGL state while I am setting up my renderer in the background. The controller will be displayed from the main thread of course. This level of understanding of OpenGl-ES is not something I deal with often, so please be gentile if my question is strange in any way :)
You absolutely can do background loading on a thread. Some of the key points:
- There is probably not much of a win to moving OGL state setup to a background thread - the total amount of change you'd induce in a context before the start of the first draw doesn't add up to a ton of time. Background loading is useful for textures and VBOs, as well as the load time that has to happen first to get the data to feed to the GL.
- You'll need to detach the context from the main thread and move it to the worker thread. We do this using pthreads to "send" the context to the worker.
- In our use, we hide the GL view to ensure that it doesn't need to be drawn while in a load state. (Frankly during load it may not contain anything useful.) So during async load the visible UI is all non-GL Cocoa.
This approach is more difficult than what you would do on the desktop: simply share the objects in two contexts (so that you can load and draw at the same time). When we looked at that approach more than a year ago, it wasn't possible on IOS; it may be possible now, I do not know.

Appropriate control for page like swiping

I currently have a UIScrollView which has a content size equal to about 50 pages, each one the size of the application view.
I have implemented scrolling by using paging and at all time keep current, previous and next page in memory, while the rest are created when required, e.g. when one swipes forward, the old 'previous' view is released and a new 'next' view is loaded.
The new pages are loaded and old released when 'scrollViewDidEndDeaccelerate' is called.
The disadvantage with this is of course that the page needs to settle completely before a new page swipe may begin.
Is there a more efficient way of doing this with a different type of control? UITableView?
I am looking for solutions with other type of controls - not UIScrollView implementations with e.g. placeholder images and loading high res on demand.
Sounds like you are on the right track as predictive caching is about the only idea I can offer...which you are doing. Maybe checking available memory and loading to a certain percentage of that might help, with caveat that you monitor the low memory warning and dump items that are the farthest from the current view location.