Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support message passing and keeping native WebView in memory when react component is unmounted #2469

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

donaldchen
Copy link

@donaldchen donaldchen commented May 4, 2022

PR Status
Ready for review. We'd like this PR to get merged if it gets approved.

Overview of Changes
By default, moving a React WebView component in the view hierarchy creates a new native WebView and refreshes the iframe. In Discord's mobile React Native apps which use react-native-webview, we need the ability to move the WebView without refreshing the iframe, and this PR adds support for that on iOS and Android by reusing the native WebView instance. We also need to be able to pass messages between the WebView and the react-native app without a react tag (e.g. when the React component for the WebView is not mounted), and this PR adds new APIs that support that, too. To test these changes, we added a "Portals" button to the RN-webview sample app. We've also been testing these changes in the Discord app.

High level react-native-webview API changes
This PR updates react-native-webview with the following new APIs

  • the webViewKey react prop- a key for accessing specific WebView instances. When this is defined, the native WebView stays in memory until explicitly released.
  • releaseWebView - a function that explicitly releases native WebViews given a WebView key.
  • the messagingWithWebViewKeyEnabled react prop - enables message passing without a react tag (i.e. without needing the react component to be mounted)
  • injectJavaScriptWithWebViewKey - supports passing messages / injecting javascript to the native WebView given a WebView key even if the react component for the native WebView is not mounted anywhere
  • addOnMessageListenerWithWebViewKey - When the webViewKey is defined, onMessage and similar callbacks like onLoadStarted don't work. This method adds a listener for messages from the WebView given a WebView key, and this handles messages even when the react component is unmounted.

How This Works

iOS Changes:
We have a singleton map where the keys are strings, and the values are WKWebViews. When React Native asks for a new view, we create a new RNCWebView instance. RNCWebView is a parent of WKWebView, and when the props say to reuse the native WebView instance, RNCWebView looks for the existing WKWebView instance from the map before it decides whether it needs to create a new WKWebView instance. Additionally, when we move a WKWebView between two RNCWebView parents, we need to remove the reference to the old parent that was held through the observer. We also have a map of web view keys to RNCWebViews, so we can remove the correct observer from the WKWebView. If we don't remove the observer when we change the WKWebView's parent, the app will crash with an EXC_BAD_ACCESS error.

Android Changes:
We renamed the old RNCWebView, which extended the Android WebView to InternalWebView. Then we were able to wrap InternalWebView with a new view, which we named RNCWebView, which is a FrameLayout. Now that InternalWebView is wrapped by the RNCWebView view group, the Android architecture can match the iOS architecture where the RNCWebView has a one-to-one relationship with the react component, and the inner / native WebView does not have a one-to-one relationship with the react component. Similar to the iOS architecture, we also have singleton maps that hold references to RNCWebViews and InternalWebViews for WebView keys.

Before and After

Here's the behavior where the iframe refreshes when webViewKey undefined.

RN.WebView.before.mov

Here's the behavior where the iframe maintains its state as the react WebView moves in the view hierarchy when webViewKey is defined.

Screen.Recording.2022-04-29.at.2.17.02.PM.mov

Testing messaging passing without a react tag
See discord#6 and discord#12 for screen recordings and explanations on how we tested the message passing between the WebView and the react-native app without a react tag.

@donaldchen donaldchen changed the title support maintaining WebView and iFrame state when moving WebView in view hierarchy request for early feedback: support maintaining WebView and iFrame state when moving WebView in view hierarchy May 4, 2022
@donaldchen donaldchen marked this pull request as ready for review May 4, 2022 15:57
apple/RNCWebView.m Outdated Show resolved Hide resolved
@donaldchen
Copy link
Author

In 03d597c , I added the changes from discord#4 (and changes from some of the commits on https://github.com/discord/react-native-webview/commits/11.18.1-discord-1 that came after that PR ). While integrating this with the Discord iOS app, I realized that I needed the ability to release the WebView with a web-view-key via a static method when the React WebView class component wasn't available.

screencap-2022-05-05T175658.393Z.mp4

@donaldchen
Copy link
Author

3a8d9c7 pulls in a change from discord#5 that fixes an EXC_BAD_ACCESS crash that I was running into when navigating away from the WebView, backgrounding the app, foregrounding the app, and navigating back to the WebView.

@mattapperson
Copy link

Overall I really like this approach, at work we have been developing this feature set as well. The API is very similar and we have it fully working on Android. Hopefully we can work together to get this feature set stable and in the open source codebase here.

@donaldchen
Copy link
Author

@mattapperson , that's exciting! Do you have this working on iOS also, or do you only have it working on Android so far? Do you have the code for your changes publicly viewable (e.g. in a fork of the repo)? If not, are you willing to share that e.g. via a PR into this repo or into https://github.com/discord/react-native-webview/commits/11.18.1-discord-1 ? I'm curious about the similarities and differences between your current approach versus my iOS changes in this PR and my proposed Android changes in the PR description

@mattapperson
Copy link

We currently have it working on both iOS and Android, but have a few bugs to work out in our iOS implementation. Nothing is public yet for this for our effort, but I hope to very soon.

@donaldchen
Copy link
Author

Nothing is public yet for this for our effort, but I hope to very soon.

@mattapperson , sounds good! Feel free to tag me when you all are ready to make that work public. I'm interested in collaborating to get the feature set stable and merged into this open-source / upstream react-native-webview code

@TheAlmightyBob
Copy link
Collaborator

I don't have time to look at this right at the moment, but this sounds really interesting. I wanted to give the one bit of early feedback that I do prefer your original plan of "wait until Android is also ready," since there's the potential that finishing Android could involve tweaking iOS/API for consistency/etc. But it sounds like you might be able to get some help with that. 😄

@donaldchen
Copy link
Author

@TheAlmightyBob , thanks for the feedback!

@Titozzz and @jamonholmgren , do you have any thoughts on the proposal in the PR description?

@github-actions
Copy link

Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions bot added the Stale label Jul 18, 2022
@donaldchen
Copy link
Author

donaldchen commented Jul 18, 2022

@TheAlmightyBob , @Titozzz , and @jamonholmgren , can we remove the "stale" label from this PR? @nealmanaktola and I have been making more changes to this in our fork of the repo here https://github.com/discord/react-native-webview/commits/11.18.1-discord-1 . I expect to eventually update this PR once our iOS (and eventually Android) implementations of this are more stable

@Titozzz
Copy link
Collaborator

Titozzz commented Jul 18, 2022

Fyi I'm in a major rewrite of the lib for the new architecture, so you'll probably have a lot of conflicts to handle.

@Titozzz Titozzz removed the Stale label Jul 18, 2022
@donaldchen
Copy link
Author

Fyi I'm in a major rewrite of the lib for the new architecture

@Titozzz , in the new architecture, on Android, is there a plan to make the Android WebView get wrapped by an RNCWebView similar to what's currently on iOS? I'm wondering, since I would've had to do that anyway to make the functionality in this PR work for Android

@cou929
Copy link

cou929 commented Sep 5, 2022

I have implemented this feature for Android by referring to this PR and discord#2 (These helped us a lot). I've forked react-native-webview/react-native-webview to a private repo on my company's organization and added diffs like this: cou929#1

(Note: This cou929#1 branch is just for sharing, so this is not the actual code I internally use in our production. Also, in this branch, we only implemented the requirements we needed, which might be not sufficient for common use cases.)

I hope this PR is going to be merged into the master eventually due to the maintenance cost of our forked branch. But it looks like it hasn't been updated in months. Do you have any plans for this PR? Is there anything I can do to help move forward?

Comment on lines 432 to 434
sharedWKWebViewDictionary[_webViewKey] = _webView;
NSMutableDictionary *sharedRNCWebViewDictionary= [[RNCWebViewMapManager sharedManager] sharedRNCWebViewDictionary];
sharedRNCWebViewDictionary[_webViewKey] = self;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the respective purpose of these 2 different dictionaries?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a high level, the RNCWebView's lifecycle is one-to-one with the lifecycle of the corresponding react-component, and the WKWebView's lifecycle is not one-to-one with the lifecycle of the corresponding react-component. sharedWKWebViewDictionary lets us keep the WKWebView alive when the first react-component unmounts and when its corresponding RNCWebView gets destroyed.

sharedRNCWebViewDictionary exists because it's possible to begin with one RNCWebView and one WKWebView for a given web view key. Then it's possible to mount a second react component for the webview with the same webview key before the first react component for the first RNCWebView unmounts. At this point, there will be two RNCWebViews with the same web view key but only one WKWebView. In didMoveToWindow for the second RNCWebView, we need to call

RNCWebView *rncWebView = sharedRNCWebViewDictionary[_webViewKey];
if (rncWebView != nil) {
  [self removeWKWebViewFromSuperView:rncWebView];
}

and remove the WKWebView from the first RNCWebView before adding it as a child of the second RNCWebView. Otherwise, the app will crash.

cc @nealmanaktola

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's interesting. Thanks for the explanation.

So, if you were you just put two WebViews on a screen with the same key, I'm guessing whichever one mounts last will "win" and the other will just be blank?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, if you were you just put two WebViews on a screen with the same key, I'm guessing whichever one mounts last will "win" and the other will just be blank?

Yeah, that's what I expect to happen. Ideally, the react / JS part of the app will typically be written in a way such that there is only one web view component on screen at a time for a given key. However, I've run into this scenario with two webview components with the same key in my earlier testing, and I felt that blanking was better than crashing

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in the process of updating the PR description, and I came across this other reason, which I had documented in an earlier version of the PR description, for having two maps: one for WKWebViews and one for RNCWebViews.

We also have a map of web view keys to RNCWebViews, so we can remove the correct observer from the WKWebView. If we don't remove the observer when we change the WKWebView's parent, the app will crash with an EXC_BAD_ACCESS error.

This may have been one source of crashes before we added that RNCWebView map.

cc @nealmanaktola , since we previously discussed whether we needed the two maps on iOS

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that updated comment you added, which I appreciate.

I was wondering though, could you not check the WKWebView's superview property for the first RNCWebView rather than looking it up in a dictionary?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheAlmightyBob , you're right! We should be able to check the WKWebView's superview property for the first RNCWebView. In these two new commits

, I've updated our iOS and Android implementations to (a) remove the map of RNCWebViews and (b) get the RNCWebView through the internal WebView's parent before detaching the internal WebView from its parent

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for linking the commits! I see the map still exists on Android, it's just used in fewer places. Was keeping it intentional, or is that change just not finished yet?

Comment on lines 736 to 742
keepWebViewInstanceAfterUnmount?: boolean;

/**
* When keepWebViewInstanceAfterUnmount is true, if two React components use the same
* key for the WebView, they will use the same native WebView instance.
*/
webViewKey?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if keepWebViewInstanceAfterUnmount is true but webViewKey is undefined?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As currently written, then in that scenario, the WKWebView will have the default behavior: its lifecycle will be roughly one to one with the lifecycle of the corresponding react component.

keepWebViewInstanceAfterUnmount needs to be true and webViewKey must be non-nullish for the WKWebView to stay alive after its corresponding react component unmounts. I wrote it this way to make the behavior more explicit. It's theoretically more flexible because then we can use the webViewKey for other cases too if necessary. I haven't actually thought of concrete examples that would need just the webViewKey though, so I'm open to changing this if that's simpler.

An alternative option is to remove keepWebViewInstanceAfterUnmount and then assume that if webViewKey is non-nullish, then we should keep the WKWebView alive after react-component-unmount.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative option is what I was originally thinking, but being explicit isn't a bad idea as long as it's documented that you need to use both.

The other use of webViewKey that I've been thinking of (and mentioned in #2640) would be to leverage this for supporting popup windows.... e.g., if web content calls window.open, the native "create window" handler could potentially create a new WKWebView in the dictionary and raise an event with the (generated?) key, which the app could then use (in RN code) to render a new WebView with that key. Theoretically, this could mean that the two WebViews would be connected as they would be in a browser.

I haven't fully thought through or tested the idea though, just mentioning as "maybe this is a scenario where you would set webViewKey but not keepWebViewInstanceAfterUnmount...."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheAlmightyBob I think that would be a good use for the webViewKey. However, @donaldchen and I believe that for now it might just make sense to keep webViewKey alone and remove keepWebViewInstanceAfterUnmount. We can reintroduce that property at a later point when needed (perhaps, when supporting pop-up windows).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like Neal addressed this in 63c586a , so I'm going to resolve this comment thread.

EDIT: Actually, tentatively, I'm going to keep the comment thread unresolved, since links to comments (which I'm using for my own tracking) don't work as reliably for me in GitHub when conversations are hidden or resolved

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donaldchen Er, does that mean you don't want me to resolve threads as I review changes...?

@donaldchen
Copy link
Author

I have implemented this feature for Android by referring to this PR and discord#2 (These helped us a lot). I've forked react-native-webview/react-native-webview to a private repo on my company's organization and added diffs like this: cou929#1
(Note: This cou929#1 branch is just for sharing, so this is not the actual code I internally use in our production. Also, in this branch, we only implemented the requirements we needed, which might be not sufficient for common use cases.)
I hope this PR is going to be merged into the master eventually due to the maintenance cost of our forked branch. But it looks like it hasn't been updated in months. Do you have any plans for this PR? Is there anything I can do to help move forward?

@cou929 , that's great that you got this working! Coincidentally, @nealmanaktola (my team member / coworker) got this working on Android in Discord's fork of react-native-webview last week in discord#11 and discord#12 .

@TheAlmightyBob , if we were to get this PR updated with both iOS and Android changes, and after this PR gets reviewed, would you be open to merging this PR? @Titozzz mentioned a new architecture for react-native-webview. Would we need to wait for those changes to complete before merging this PR?

Do you have any plans for this PR? Is there anything I can do to help move forward?

I'll get back to you on that after I talk with my team and after @TheAlmightyBob responds to the question above. I'd like this PR, eventually with both iOS and Android changes, to get merged into react-native-webview/react-native-webview.

@nealmanaktola
Copy link

if we were to get this PR updated with both iOS and Android changes, and after this PR gets reviewed, would you be open to merging this PR?

@TheAlmightyBob, would you prefer a PR per platform (one for iOS and one for Android) or a single PR with both iOS and Android changes?

@donaldchen
Copy link
Author

donaldchen commented Sep 6, 2022

Do you have any plans for this PR? Is there anything I can do to help move forward?
I'll get back to you on that after I talk with my team and after TheAlmightyBob responds to the question above.

@cou929 , for now, you can use Discord's fork of react-native-webview if you'd like to use these features on both iOS and Android https://github.com/discord/react-native-webview/commits/11.18.1-discord-1 . Later, depending on the response to #2469 (comment) , @nealmanaktola or I can take care of updating this PR, so we can hopefully get the iOS / Android changes merged into react-native-webview/react-native-webview.

@Titozzz
Copy link
Collaborator

Titozzz commented Sep 6, 2022

You can check my work for new arch the branch is published already and 95% of features are good

@TheAlmightyBob
Copy link
Collaborator

would you be open to merging this PR?

Yes, but...

@Titozzz mentioned a new architecture for react-native-webview. Would we need to wait for those changes to complete before merging this PR?

...I haven't been involved with this work and don't know the scope/timeline. I guess I'd encourage checking out his branch as he mentions above?

would you prefer a PR per platform (one for iOS and one for Android) or a single PR with both iOS and Android changes?

Although I expect it'll be very large, I think I'd lean towards a single PR. But if there's a logical way to organize the commits for reviewing incrementally, that might help.

@donaldchen
Copy link
Author

@Titozzz , do you have a rough estimate on when https://github.com/react-native-webview/react-native-webview/commits/new-arch will merge to master?

@nealmanaktola and I will check out that branch and see if there are any major conflicts with out changes. Depending on when that new-arch branch is expected to merge, @nealmanaktola and I could either make our PR against master or against new-arch. @TheAlmightyBob , do you have any preferences on which branch we should make the PR against? If we were to make the PR against master, would you prefer us updating everything on this PR, or would making a completely new PR be easier?

Although I expect it'll be very large, I think I'd lean towards a single PR. But if there's a logical way to organize the commits for reviewing incrementally, that might help.

Sounds good! @nealmanaktola and I will initially plan on creating a single PR for both iOS and Android.

@donaldchen
Copy link
Author

Hey @donaldchen , the last batch of changes look good to me, my comments are mostly small things.
The two biggest "high-level" concerns on my mind (neither of which I think we will be news to you) are:
The new architecture. The big refactor has been completed/released, so this will need to be made compatible (e.g. most of the Android implementation has been converted to Kotlin). I don't expect any major issues/incompatibilities, but not 100% certain
Documentation/commenting. This definitely introduces complexity, and we want to make it as easy as possible both to use and to maintain

Hey @TheAlmightyBob , thanks for the feedback! That makes sense. I'd like to update this PR to work with the new architecture, and I'll plan on adding more documentation, too. My availability is still TBD, but I'm hoping I can come back to this in one to two months. We'll tag you when this is ready for another review. Thanks!

@DavidGOrtega
Copy link

DavidGOrtega commented Jul 4, 2023

@donaldchen I have tried to use your branch, however the webview shows a blank page. It does not load for me.

i have added

<WebView
        webViewKey="web1"
        messagingWithWebViewKeyEnabled={true}

        ref={webviewEl}

My code also post messages

 const js = `
window.WebViewBridge = {
  onMessage: (message) => {
    const { type, data } = JSON.parse(message || '{}');
    document.dispatchEvent(new CustomEvent(type, { detail: data }));
  }
}

any hint?

@TheAlmightyBob
Copy link
Collaborator

@DavidGOrtega Does it work if you use it "normally" (without the webviewkey stuff)?

I haven't used the branch with the latest changes, but a previous version was working for me.

@donaldchen
Copy link
Author

donaldchen commented Jul 5, 2023

@DavidGOrtega , I haven't been available to test this branch recently, but I hope to test more when I get around to working on making this work with the new react native architecture #2469 (comment) .

Like @TheAlmightyBob suggested, you could try an older commit such as 413cae3 . That one was before my last batch of changes in March.

Also, what are you passing in for the source prop? If you pass in what the Portals.tsx example uses, does it work?
https://github.com/discord/react-native-webview/blob/237796aced1f986a5f8c33d5be295c5fbf74e728/example/examples/Portals.tsx#L160

https://github.com/discord/react-native-webview/blob/237796aced1f986a5f8c33d5be295c5fbf74e728/example/examples/Portals.tsx#L82-L103

My code also post messages
const js = `
window.WebViewBridge = {
onMessage: (message) => {
const { type, data } = JSON.parse(message || '{}');
document.dispatchEvent(new CustomEvent(type, { detail: data }));
}
}
any hint?

Can you share more context on where this code is running? Is this code that runs inside the WebView?

You can view https://github.com/discord/react-native-webview/blob/237796aced1f986a5f8c33d5be295c5fbf74e728/example/examples/Portals.tsx#L215 for an example of posting messages to the WebView and https://github.com/discord/react-native-webview/blob/237796aced1f986a5f8c33d5be295c5fbf74e728/example/examples/Portals.tsx#L112 for an example of listening to messages sent from the WebView back to the react-native app that hosts the WebView. One difference I see is that your code uses window.WebViewBridge while my example uses window.ReactNativeWebView.postMessage

@DavidGOrtega
Copy link

DavidGOrtega commented Jul 6, 2023

@DavidGOrtega Does it work if you use it "normally" (without the webviewkey stuff)?

Yes

If you pass in what the Portals.tsx example uses, does it work?

Let me try it.

The issue is more puzzling than I thought. Sometime loads the page, sometimes does not. For sure what is happening also is that If it loads and the device gets a locked screen if I go back the blank screen is there.
Have I determined how the white screen appears at the beginning? Sort of.
My app requests lots of permissions. Using this webview if it does not ask for all the permissions... it works, if it takes longer to reach the point where the UI should display it does not.

This is tested in android 11 within a real device

@github-actions
Copy link

github-actions bot commented Sep 5, 2023

Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@donaldchen
Copy link
Author

Small update from my end: I had begun updating this to support the new arch in discord#27 , but I haven't had time to get those changes fully working yet. I hope to revisit those changes again some time in the future

Copy link

Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions bot added the Stale label Nov 12, 2023
@donaldchen
Copy link
Author

Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP!

@TheAlmightyBob , I'd like to keep this PR open if possible. I'm still hoping to get back to this in the future, but I don't have a specific timeline yet

@Darren120
Copy link

Darren120 commented Dec 6, 2023

Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP!

@TheAlmightyBob , I'd like to keep this PR open if possible. I'm still hoping to get back to this in the future, but I don't have a specific timeline yet

i tried this PR, it crashes if keying it into a modal, or another screen, then unmounting that screen

@donaldchen
Copy link
Author

donaldchen commented Dec 7, 2023

i tried this PR, it crashes if keying it into a modal, or another screen, then unmounting that screen

@Darren120 , this branch https://github.com/discord/react-native-webview/commits/11.18.1-discord-1 has a more stable version of this code. For the branch in this PR (https://github.com/discord/react-native-webview/tree/11.18.1-discord-2), I haven't had time to resolve all the errors and issues yet when making it work with the new react-native architecture

@Darren120
Copy link

i tried this PR, it crashes if keying it into a modal, or another screen, then unmounting that screen

@Darren120 , this branch https://github.com/discord/react-native-webview/commits/11.18.1-discord-1 has a more stable version of this code. For the branch in this PR (https://github.com/discord/react-native-webview/tree/11.18.1-discord-2), I haven't had time to resolve all the errors and issues yet when making it work with the new react-native architecture

UPDATE:
haha sorry about that, i forgot to prebuild my expo while jumping around branches. no more crashes! excellent work! i hope we can get this merged!

@Darren120
Copy link

i tried this PR, it crashes if keying it into a modal, or another screen, then unmounting that screen

@Darren120 , this branch https://github.com/discord/react-native-webview/commits/11.18.1-discord-1 has a more stable version of this code. For the branch in this PR (https://github.com/discord/react-native-webview/tree/11.18.1-discord-2), I haven't had time to resolve all the errors and issues yet when making it work with the new react-native architecture

An issue I am encountering is cookies are either not being shared if another webview sets them, or its being resetted
I think it broke sharedCookiesEnabled

@Darren120
Copy link

i tried this PR, it crashes if keying it into a modal, or another screen, then unmounting that screen

@Darren120 , this branch https://github.com/discord/react-native-webview/commits/11.18.1-discord-1 has a more stable version of this code. For the branch in this PR (https://github.com/discord/react-native-webview/tree/11.18.1-discord-2), I haven't had time to resolve all the errors and issues yet when making it work with the new react-native architecture

further debugging, seems like the cookies are not being synced if a web view is activity being viewed while portaled.
for example, i am showing the web view in another screen by portaling it there, but after a while my auth cookies are not synced. if i stay on the original screen, the cookie remains synced, and navigating to the portaled webview works fine. so i guess while webview is portaled and activity being viewed, it is not syncing cookies

Copy link

github-actions bot commented Feb 7, 2024

Hello 👋, this PR has been opened for more than 2 months with no activity on it. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions bot added the Stale label Feb 7, 2024
@github-actions github-actions bot closed this Feb 14, 2024
@Titozzz Titozzz reopened this Apr 1, 2024
@Titozzz Titozzz removed the Stale label Apr 1, 2024
@Titozzz
Copy link
Collaborator

Titozzz commented May 10, 2024

FYI: I still like the idea behind that PR, I'm thinking of rewriting webview around new arch with this capability

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants