Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Shell recreates a new custom renderer when tap back #9073

Open
Erdogan34 opened this issue Jan 3, 2020 · 21 comments
Open

[Bug] Shell recreates a new custom renderer when tap back #9073

Erdogan34 opened this issue Jan 3, 2020 · 21 comments

Comments

@Erdogan34
Copy link

Description

Shell recreates a new custom renderer for a web view when coming back instead of using the prior one.

Steps;
Tab 1 name is "Web" (includes a webview)
Tab 2 name is "Profile"

If I tap the Web tab, I see the home page of the webview. If I tap the "Profile" tab and then back to the "Web" tab, each time creates a new webview and fires the OnElementChanged method inside custom webview.

@Erdogan34 Erdogan34 added s/unverified New report that has yet to be verified t/bug 🐛 labels Jan 3, 2020
@pauldipietro pauldipietro added this to New in Triage Jan 3, 2020
@samhouts
Copy link
Member

samhouts commented Jan 3, 2020

@Erdogan34 Can you please attach a small project that demonstrates this issue? Thanks!

@samhouts samhouts added s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Jan 3, 2020
@samhouts samhouts moved this from New to Needs Info in Triage Jan 3, 2020
@samhouts samhouts added this to Backlog in Shell Jan 3, 2020
@Erdogan34
Copy link
Author

@samhouts samhouts removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Jan 4, 2020
@PureWeen PureWeen self-assigned this Jan 4, 2020
@PureWeen
Copy link
Contributor

PureWeen commented Jan 4, 2020

This issue is similar to this
#8581

But just a different version of it and I'd say worse 👎 since bottom tabs are the default so it'll just dispose the whole hierarchy as you navigate by default.

When you click between bottom tabs it swaps out the fragment instead of just retaining it and hiding it.

The tricky thing here is gauging the offscreen limit to use so that too many tabs doesn't slow down the performance too much.

But we could by default just use some basic value like 3 or so

@PureWeen PureWeen added e/3 🕒 3 and removed s/unverified New report that has yet to be verified labels Jan 4, 2020
@PureWeen PureWeen moved this from Needs Info to Ready For Work in Triage Jan 4, 2020
@PureWeen PureWeen added this to the 4.4.0 milestone Jan 4, 2020
@PureWeen PureWeen added this to To do in Android Ready For Work via automation Jan 4, 2020
@PureWeen PureWeen added this to To do in v4.4.0 via automation Jan 4, 2020
@Erdogan34
Copy link
Author

Thank you @PureWeen.

I wish a chance and an option to use the behavior for any specific tab.

For example;
<Tab Title="Profile" TapDispose="false">
...


...

@PureWeen
Copy link
Contributor

PureWeen commented Jan 5, 2020

@Erdogan34
Yea there was some talk here about an API for this

#1897 (comment)

Which we could generalize to any forms element which would be really useful for cases where elements are removed from the cross platform tree but you don't want the renderer to dispose

Ideally we can reinvigorate that and then apply it here

@Erdogan34
Copy link
Author

My eye is on the road :)

@samhouts samhouts added this to To do in Other Ready For Work Jan 10, 2020
@samhouts samhouts removed this from Ready For Work in Triage Jan 10, 2020
@Li-Yanzhi
Copy link

I have a similar issue about this, if you have two Tabs and each one contains a WebView like this:

<TabBar>
        <Tab Title="App" Icon="tab_app.png">
            <ShellContent Title="Web1" ContentTemplate="{DataTemplate local:BrowserPage1}" />
        </Tab>
        <Tab Title="App" Icon="tab_app.png">
            <ShellContent Title="Web2" ContentTemplate="{DataTemplate local:BrowserPage2}" />
        </Tab>
</TabBar>

And then when you switch between Tabs, both Webview will reload content when it is activated and cannot keep the loaded content and scroll position.

@Erdogan34
Copy link
Author

Hello @Li-Yanzhi, do you have the problem with iOS too?

@ahmedalejo
Copy link

@Erdogan34
I wish a chance and an option to use the behavior for any specific tab.

For example;

TapDispose sounds to implementation specific, what about IsContentPreserved

<Tab Title="Profile" IsContentPreserved="True">

@Erdogan34
Copy link
Author

Erdogan34 commented Mar 30, 2020

TapDispose sounds to implementation specific, what about IsContentPreserved
<Tab Title="Profile" IsContentPreserved="True">

@ahmedalejo
Is this behavior available with the new xf version or already has previous versions?

My xf version is 4.5.0.495 but I couldn't use the TapDispose and IsContentPreserved behaviors, not coming with IntelliSense.

@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 14, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@pcdus
Copy link

pcdus commented Nov 5, 2020

What's new about this issue?

@samhouts Could you give us any news about this fix?

@Erdogan34
Copy link
Author

What's new about this issue?

@samhouts Could you give us any news about this fix?

Still a mystery

@fernandomondo
Copy link

fernandomondo commented Dec 1, 2020

I have the same behavior, with two page (one with webview and other without).

When webview reload, it lost all sessionstorage too.

I opened a question in microsoft q&a :

https://docs.microsoft.com/en-us/answers/questions/182375/webview-session-storage-lost-when-navigate-between.html

@fernandomondo
Copy link

I keep trying to do some workaround, especially when the app is in background, because the users loses all the data they was typing.

Someone can help me?

I tried to create a static webview, but it did'nt work.

public class WebsitePage : ContentPage
    {
        public static WebView webView;
        public WebsitePage()
        {
            Title = "My WebsitePage";

            if (webView == null)
            {
                webView = new WebView();
                Content = webView;

                webView.WidthRequest = 1000;
                webView.HeightRequest = 1000;

                webView.Navigated += WebMailView_Navigated;

                webView.PropertyChanging += WebMailView_PropertyChanging;

                webView.PropertyChanged += WebView_PropertyChanged;
            }
        }

@kaanid

This comment was marked as off-topic.

@Erdogan34

This comment was marked as off-topic.

@greg84
Copy link

greg84 commented Apr 5, 2022

Any update on this @jfversluis ? It's been assigned to every service release since 5 but not fixed, and the board for SR11 doesn't seem to have been populated yet.

If it can't be fixed or isn't a priority I'll need to remove Shell from my project (as I need a custom renderer for webview and on Android tab navigation needs to preserve the original webview that was open when the user navigated away from the tab, not recreate it).

Would appreciate an update regarding this issue's priority, as I'll need to plan in some additional work on my project if this can't be resolved soon-ish. Many thanks!

@jfversluis
Copy link
Member

At this moment I can't tell you when this will be fixed. So if those are your options I guess you will have to do what you have to, or of course, is this really a priority to you, feel free to provide a PR with a fix. Thanks!

@mcguu
Copy link

mcguu commented Apr 8, 2022

@jfversluis I want to fix it but I do not know how to do it.

@ronnycsharp
Copy link

I have the same issue.

@rurivera6
Copy link

So will this ever be fixed? Only the Android version does this.

@PureWeen PureWeen removed their assignment Aug 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Shell
  
Backlog
v4.4.0
  
To do
Development

No branches or pull requests