WebView too slow - performance

I have an app that loads a page from my server inside of a webview. In my app, I have a native menu that reloads my webview with a new page when clicked.
My insane problem is that after navigate within the app clicking on menu more then 5 times, the webview become reaaally slow. Doesn't matter which link and even if I try to reopen a previously page, is still slow.
I tried to use this in my android-manifest file:
android:hardwareAccelerated="true"
I also tried to deactivate the cache, doing this:
myWebView.webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
Anyone has an idea about my problem? What can be?
Thanks!

Was a memory leak problem! I had to call these functions before load a new url, otherwise, the garbage collector seems not work.
mWebView.removeAllViews();
mWebView.clearView();
mWebView.destroy();

Related

High Sierra WebView blocks anchor tag navigation

I have a Mac app that displays info in a WebView. Quite an old app now and in Objective-C which I am rapidly forgetting.
The WebView contains anchor tags to allow navigation within the pages, both by clicking on links in the page displayed, or by clicking tabs in the UI which send Javascript to the WebView. In High Sierra this no longer works although it displays no error.
It appears that I need to implement isKeyExcludedFromWebScript: but my attempts to do so have failed.
Do I need to sub-class WebView? Putting isKeyExcludedFromWebScript: and isSelectorExcludedFromWebScript: in the View Controller containing the WebView doesn't work - they never get called.
If anyone has any advice or examples, I would be most grateful.
I am afraid that the answer will be to upgrade the app to use WKWebView but I was hoping for a quick work-around until I get time to do that.
Answering my own question here as I have worked out a solution.
The problem was that I was loading an HTML string into the WebView and when I tried to use internal navigation links, it didn't have a base URL to use as a prefix and so the anchor navigation never worked.
It used to work, prior to High Sierra, so there must be something new about how WebViews operate.
The solution was to save the HTML string to a temporary file and have the WebView load that file's URL instead of loading the string directly.
This applies to both WebView and WKWebView.

Is there a Xamarin event I can attach to for when a page finishes being laid out?

I have a Xamarin.Forms page that loads fine. If I click a button on the page that causes the Content to be changed, the whole UI shifts a little bit. I am assuming this is happening due the equivalent of a ForceLayout happening when I change the Content page. It is a fairly complex page, with a couple RelativeLayouts inside a StackLayout.
After this happens once, it never happens again, interestingly enough. So I am thinking if I do a ForceLayout somewhere, or even just reset the Content twice on load it might fix it for me. The trouble is I don't know where to make that happen. If I try it in the constructor it does not help. Any ideas?
Found my answer. I just set the content a second time in the Appearing event. Problem goes away. I love Xamarin but the layouts in forms feel like quite a hack sometimes, particularly RelativeLayouts.

Webview Load to touch

Hello Im New in Xcode Development and i try to make a Easy app
My App:
my mobile app have 5 Tabs, All the tabs have Webview and the problem is to load the app,
Everything works very slow.
I have seen some applications when changing tab load the Webview.
anyone can help me with this.
Sorry for my English i use Google translate.
Thanks.
#user1744203 I can get u now. You can call all the Tab actions in MainViewController then all the actions will be loaded then this reduces the loading time.Still having problem then you can use jQuery which traverse HTML documents speedly...
Maybe this click on this link can help you in fixing jQuery
Hope this Helps!!!!

Chrome Plugin image persists after close

I have been developing a media player browser plugin for the past few month using Firebreath, but I do not think this is a Firebreath problem.
Currently I am stuck on this weird problem that occurs when one tries to reload the webpage containing the plugin. The image that was being displayed before the reload will stay stuck on the top of screen. The new reloaded plugin will be alive and well behind it but the old image will stay stuck their on the screen forever. If I scroll or resize the browser or even change URLs the image will stay put, however If I move the browser the image will follow. The image stays after closing a tab, but leaves when closing the window
Here is a screenshot that demonstrates what I am talking about.
http://i.imgur.com/asB7i.jpg
( I am a new user so I cant post images )
Has you can see I left my plugin's page and went to the Firebreath website and the image still persists.
This problem happens on both windows and linux, much less frequently on linux, and happens when using both directx and opengl. But only happens on chrome.
Just wondering if you, or anybody else, has any thoughts, suggestions, or insights as to what might be happening. I've tried everything including atrocious hacks and nothing seems to work.
Thank you.
Your problem is most likely that you aren't tearing down your directx or opengl context when the DetachedEvent fires. AttachedEvent is the earliest you can set it up, and DetachedEvent is the latest you can leave it running.

WebView slow loading

In a cocoa / Mac app I am using a WebView to load a series of YouTube videos (5). When it is loading my whole application locks up for 5 seconds or so.
Is there a way I can load it so it doesn't freeze the rest of the application?
Thanks
eg:
[[webView mainFrame] loadHTMLString:html baseURL:[NSURL URLWithString:#"http://youtube.com"]];
Unfortunately, you cannot render a WebView except on the main thread. This is a basic limitation of the class. I would begin investigating why your page takes so long to render. My hunch: Javascript or a plugin.
I usually like to start by using Safari to see if it has the same issues. You can drag an HTML file onto Safari to load it easily. If Safari shows the same problem, then you can use Safari's Develop tools to profile it. (Preferences, Advanced, Show Develop menu in menu bar.)
If Safari doesn't have a problem, that's actually good, because it means your problem is definitely solvable (if Safari can do it, you should be able to achieve the same thing). Here are some things to try out:
Instruments. Try to see what WebView is taking its time on. Focus first on "all samples" for the main thread. This is usually what leads to the app hanging.
Simplification. Try stripping things out of the webview, especially javascript, until you find the piece that's causing the problem.
Implement the WebResourceLoadDelegate methods to see what piece seems to be causing the problem. The information given by this can be misleading, since it has to do with when things are downloaded, not when they are rendered, but it can give a sense of where in the page you're hanging.

Resources