UWP Webview has no resume function - webview

UWP Webview I am using it in C#/xaml app, to load websites, it has stop() method to halt the content loading but when I want to resume content loading, after it being stopped, how can I do that? for example, I have several webviews on same page, and at start I halt all of them for good performance, but then according to user commands I want to resume their content loading, and then if I want to stop again I can stop, also does stop method means that it pauses the content load? or stops it completely? so that next time we have to navigate again?

Stop is like the browser "Stop" button. It halts all content download and is not resumable.
You'll need to reload/refresh the page that you want to "resume." Depending on the web page, some of the content maybe cached locally already so to the user it may appear as if it loads more quickly.

Related

How to manage background tasks iOS

Lets say a user starts async request in PageViewController flow then dismisses. If they quickly bring back PageViewController it won't navigate to the correct page because an async request (that determines the next logical page to show) is underway. Is it standard to prevent the user from dismissing controller or asking them not to? If not, how do I manage background tasks, so I know to keep loading screen up and wait to navigate pages until last request completes and changes state/server side data?

Load entire application at start up

I have a tabbed iOS application with each of the tabs having some sort of json request so the view loads ever so slightly slowly. I want to remove that lag completely so I'm wondering if there is a way to call the ViewDidLoad function from each of the classes during the login phase of the application.
if (login == "Success") {
UserDefaults.standard.set(true, forKey: "isUserLoggedIn");
UserDefaults.standard.synchronize();
DispatchQueue.main.async {
// Load all resources here
}
}
I can understand this can be bad practice if the app is very large, but I think in this scenario the app isn't huge, but the lag between the view controllers is enough to be annoying. I would rather have the user wait at the start for 3-5 seconds whilst everything loads, and have a smooth experience once inside. Is there a way to do this?
You shouldn't call the lifecycle functions of the viewcontroller for yourself. The viewDidLoad function will be called when the view has been loaded.
Apple: This method is called after the view controller has loaded its view hierarchy into memory.
So calling let _ = viewController.view will trigger the view creation and the call of this function.
But i think it's much better to have a startup phase instead. Think about a 'startup'-screen that downloads everything you need (with maybe a spinner and a text) and moves automatically to the content (the tabbar controller) when done. That may also fix the problem of a low network connectivity (think about a download that take a minute for example). You may display that screen modally above or as screen before the tabbbar controller.
If you don't like the idea of a startup phase you may also design your ui responsive. Start the download whenever needed / regularly and update your ui according to the results when ready. The ui will be fast then, but uses last known data. The meaningfulness and implementation depends on your content.
Update
On second thought: If you already have a server login screen, why not download the content directly after the successful download as part of the login? Users do not know if you are still checking the login or downloading some necessary data. You may say that login is only successful if server login AND download are finished successfully.

Web view did finish delegate method is not called in iOS

I am developing a product in which we have to render a web page. This particular web page can invoke our objective c methods. This is implemented using EasyJSWebview. Once the web page is loaded that has a timer running there. Web page is shown properly till the timer reaches the desintaiton time. Once that timer is reached, that page is reloaded with some event content. There the problem is occurred. The problem is that the page starts to load, activity indicator is shown but it does not close of finishing delegate method is not called. So, Activity Indicator is shown forever. But, Page is not loaded yet. But, If I navigate to the side menu and reload the page manually, That event web page is loaded properly and If I press home button when it reloads with the activity indicator, the app closes and I open it again, that activity indicator is hidden and the page is not loaded yet.
There are lots of hits to server during this event. It occurs only in live. But, If I test it in our development server with many hits with the help of JMeter, our application works properly.
So, It occurs only in live. Our live deployment consists of many replica's of servers. Can it occur due to this too?.
I am not able to find any solution for this. Please let me know if you have any solution for this.
Thanks in advance.
This was just an internet issue. The present code works properly.

UWP webview slows the app

I have multiple webviews on one page, when app loads, the main page stucks for almost 8-10 seconds, I am guesing tht is the time taken by all webviews to load respective websites, why does Ui stucks, how can I make loading of webviews asyncronous so that Ui remains responsive?
you can try https://learn.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/web-view#threading-behavior and move the processing to a different thread or process it did help me a bit but not much https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.webviewexecutionmode?view=winrt-19041

Change zoomScale and contentOffset of UIScrollView in UIApplicationStateBackground state

I know it's not recommended to change any view appearance when the application is moved to background state, but for my specific task I cannot postpone this activity and I really like to complete it in a couple of seconds after the user hits the home button.
That's what I do:
I load a webpage in a UIWebView and after loading completion I change the contentOffset and zoomScale in order to make a specific screenshot of that webpage. When the app is in active application state everything works fine.
Now I wanted to add some more multitasking capabilities. I encapsulated the above described webpage loading and rendering activity in a protected background task (iOS Task Completion), in order to complete it even when the user hits the home button.
I have noticed that the page loading and the rendering of the webpage screenshot (with the renderInContext: method) works just fine in background, BUT it seems that the webview (i.e. the encapsulated UIScrollView instance) does not react on setContentOffset: and setZoomScale: messages as soon as the app is in background..
So I'm asking you if you know any alternatives to change the content offset / zoomscale? (modifications directly on CALayer?) Or any method to "force" the scrollview to perform the content changes even in background.
PS: On the iOS simulator everything works fine even in application background state, but on real devices it does not.
EDIT: I have created a simple demo project that demonstrates the issue. You can download it here (please read the instructions in the zip file): http://dl.dropbox.com/u/3556271/BackgroundBugDemo.zip
I appreciate every hint or tip. Thanks!

Resources