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

BrowserView: Remove webview and initialize BrowserView. #793

Closed
wants to merge 28 commits into from

Conversation

vsvipul
Copy link
Collaborator

@vsvipul vsvipul commented Jul 17, 2019

What's this PR do?
Implements BrowserView with similar functionality as webview.
View is a class which we will use, it extends electron's BrowserView
class. ViewManager will be used to create, manage and delete views
in the main process. Removes all usage of webview and adds
an initial implementation of BrowserView.

You have tested this PR on:

  • Windows
  • Linux/Ubuntu
  • macOS

app/main/view.ts Outdated Show resolved Hide resolved
app/main/view.ts Outdated Show resolved Hide resolved
app/main/view.ts Outdated Show resolved Hide resolved
@vsvipul vsvipul force-pushed the bv-migrate branch 3 times, most recently from eeb7ca9 to c2c7bc1 Compare July 18, 2019 11:17
@vsvipul
Copy link
Collaborator Author

vsvipul commented Jul 18, 2019

I think this is ready. @akashnimare @abhigyank . Should i wait for this to be merged or add subsequent commits on top of this PR ?

@akashnimare
Copy link
Member

add subsequent commits on top of this PR

Do this.

@abhigyank
Copy link
Collaborator

I think you need to rebase with zulip:browserview branch otherwise the two extra commits from master would also come in the changes.

@vsvipul
Copy link
Collaborator Author

vsvipul commented Jul 19, 2019

I think you need to rebase with zulip:browserview branch otherwise the two extra commits from master would also come in the changes.

I think it will be better to keep this branch updated with master as well, so that we don't face merge conflicts while merging into master later.

@vsvipul vsvipul changed the title BrowserView: Add View and ViewManager to main process. BrowserView: Remove webview and initialize BrowserView. Jul 23, 2019
}
}

export = new ViewManager();
Copy link
Member

Choose a reason for hiding this comment

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

Do export default const ViewManager = new ViewManager(); or something else but not this export = syntax. We need to stop using this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

export default const ViewManager = new ViewManager(); This doesn't seem to be working. Can you try this?

Copy link
Member

Choose a reason for hiding this comment

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

So I made a mistake here, this could be either export default new ViewManager() or

const viewManager = new ViewManager();
export default viewManager();

// then in index.ts
import ViewManager from './viewmanager';

I prefer the second one just because export default new ViewManager(); looks awkward to me (but that just me).

Copy link
Member

Choose a reason for hiding this comment

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

@vsvipul is this being taken care of?

@abhigyank
Copy link
Collaborator

This is some really good work. One important observation that I have - Moving to BrowserView shifts almost everything to the main process. Most of the functions surrounding webview previously was in renderer/main.js since webview was in renderer. In this change, we have kept the structure same and in places where webview functions are called we are using ipc to move those calls to the main process - even for functions like create, reload, load, switch etc. Now that browserView resides in the main process, would it make sense for us move all these important browserView actions entirely to the main process from renderer/main instead of doing ipc calls?
I am not sure if ipc calls use much CPU or memory, but I think it would make sense to have the the basic initialisation actions moved to main process.

@vsvipul
Copy link
Collaborator Author

vsvipul commented Jul 25, 2019

I am not sure if ipc calls use much CPU or memory, but I think it would make sense to have the the basic initialisation actions moved to main process.

@abhigyank Yes, the initialization can be moved to main process, but switching tabs, and everything else, will still require ipc Calls.

Copy link
Member

@priyank-p priyank-p left a comment

Choose a reason for hiding this comment

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

@vsvipul I reviewed the first two commits and left minor comments. I don't like the passing index programmatically and having to manage it; I do rather the code handle that. Let's come up with a better model here, I guess we can come up with a better model if you describe what exactly it's needed for.

app/main/view.ts Show resolved Hide resolved
app/main/viewmanager.ts Show resolved Hide resolved
app/main/viewmanager.ts Outdated Show resolved Hide resolved
app/main/viewmanager.ts Outdated Show resolved Hide resolved
app/main/viewmanager.ts Outdated Show resolved Hide resolved
}

create(props: ViewProps): void {
if (this.views[props.index]) {
Copy link
Member

Choose a reason for hiding this comment

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

I think I mentioned this before but, the allowing a programmer to pass and track IDs to pass into this index field here is very brittle; it seems to call for trouble. Can we make this auto generated and make readonly property?

app/main/viewmanager.ts Show resolved Hide resolved
@vsvipul
Copy link
Collaborator Author

vsvipul commented Jul 26, 2019

@vsvipul I reviewed the first two commits and left minor comments. I don't like the passing index programmatically and having to manage it; I do rather the code handle that. Let's come up with a better model here, I guess we can come up with a better model if you describe what exactly it's needed for.

Index is needed to create a view with that particular index so that we can easily remove and change to that view using only the index later, nothing else is required. What better model do you propose?

@priyank-p
Copy link
Member

@vsvipul OK, here is what we can do, we can have a internal variable in view.t say viewIndex that is set to 0 at first. Then when we create a view in constructor we can do this.index = viewIndex; and increment it viewIndex++. That way we can access the index and do whatever we want like remove, select but we just don't have to pass it in.

Copy link
Member

@priyank-p priyank-p left a comment

Choose a reason for hiding this comment

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

Left some more comments, I like how we get to change tab.webview.props.name -> tabs.props.name.

app/main/index.ts Outdated Show resolved Hide resolved
app/main/menu.ts Outdated Show resolved Hide resolved
app/main/view.ts Outdated Show resolved Hide resolved
app/main/viewmanager.ts Outdated Show resolved Hide resolved
app/main/view.ts Outdated Show resolved Hide resolved
app/main/viewmanager.ts Outdated Show resolved Hide resolved
app/main/menu.ts Outdated Show resolved Hide resolved
app/main/view.ts Outdated Show resolved Hide resolved
@akashnimare
Copy link
Member

@kanishk98 let's try to find out which commit broke the app on macOS.

@kanishk98
Copy link
Collaborator

@akashnimare I'm doing that right now. I don't think it's something to do with Electron, though - this seems to stem from a bug in activateTab(). I'm trying to fix it right now, will text you and Vipul on czo if I find something.

@akashnimare
Copy link
Member

@kanishk98 any luck in debugging?

@kanishk98
Copy link
Collaborator

kanishk98 commented Oct 1, 2019

any luck in debugging?

Yeah, the app breaks at commit 9c4a3de. I'm currently working to see where the Mac-specific problem is.

@kanishk98
Copy link
Collaborator

kanishk98 commented Oct 1, 2019

Ah okay, the solution is almost too simple:

In viewmanager.select(), we need to reverse the order of function calls from

this.fixBounds();
mainWindow.setBrowserView(view);

to

mainWindow.setBrowserView(view);
this.fixBounds();

@vsvipul can you make the changes? I just tried this out on a Mac - it should solve our problem.

@akashnimare
Copy link
Member

@kanishk98 are you sure this works for you? Can you post a gif here?

@kanishk98
Copy link
Collaborator

Can you post a gif here?

I can't post a gif right now (it's not my Mac that I tested this on), but you can fetch my branch browserview onto your system and try it out. Do let me know if it doesn't work.

@akashnimare
Copy link
Member

@vsvipul can you fix the merge conflicts?

@vsvipul
Copy link
Collaborator Author

vsvipul commented Oct 3, 2019

@akashnimare working on it right now. Sorry for the late response. Was a little busy this week.

@vsvipul
Copy link
Collaborator Author

vsvipul commented Oct 3, 2019

I am having some difficulty porting the new notification option to browser view.

@kanishk98
Copy link
Collaborator

I am having some difficulty porting the new notification option to browser view.

I think I can help with that. Can you tell me what the issue is?

@vsvipul
Copy link
Collaborator Author

vsvipul commented Oct 3, 2019

@kanishk98 How do i set the enabled state in the rendered process for that setting because the current URL in browser view is in the main procesS?

@kanishk98
Copy link
Collaborator

I can think of the following methods:

  1. Use a synchronous IPC call (probably the simplest, but I'd avoid this).
  2. Save a loggedIn flag in domain.json for all orgs that you can read when deciding whether enabled is true or not. Said flag is updated when the URL of the view changes.
  3. I'm a little doubtful about this one, but we can also maintain an instance variable in ViewManager that maps server URLs to loggedIn status. Updated in the same way as (2).

Since I'm also working on this right now, I'll try what works on my end and let you know. Text me on czo if you have any further questions.

@akashnimare
Copy link
Member

@kanishk98, @vsvipul awesome. Let's try to merge this asap since it's a blocker for other PRs.

@vsvipul
Copy link
Collaborator Author

vsvipul commented Oct 4, 2019

@akashnimare Apparently, rebasing it automatically messes up my whole branch. The title property which I added gets removed, function names get changed due to which many ipc Calls stop working. I'll have to do this commit by commit myself. So, it is going to take some time.

@akashnimare
Copy link
Member

@vsvipul maybe reset the branch locally and git pull + rebase and fix merge conflicts? There are three files mainly where the conflicts thing happening.

@vsvipul
Copy link
Collaborator Author

vsvipul commented Oct 5, 2019

@akashnimare Yeah, i did exactly that, but that still messes up a lot of stuff. I am doing it but will take some time.

@akashnimare
Copy link
Member

@vsvipul let me know if you need help. Gotta merge this asap since a lot of other PRs are still pending.

@vsvipul vsvipul closed this Oct 9, 2019
@vsvipul vsvipul reopened this Oct 9, 2019
@vsvipul
Copy link
Collaborator Author

vsvipul commented Oct 9, 2019

@akashnimare As I am currently a little busy with academic work, I have given access to my branch to @kanishk98 a few days back. He is working on rebasing and migrating the notification option he added earlier.

@akashnimare
Copy link
Member

Cool, thanks for the update!

@zulipbot
Copy link
Member

Heads up @vsvipul, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/master branch and resolve your pull request's merge conflicts accordingly.

@vsvipul
Copy link
Collaborator Author

vsvipul commented Jul 18, 2020

Closing this in favor of #831 .

@vsvipul vsvipul closed this Jul 18, 2020
@vsvipul
Copy link
Collaborator Author

vsvipul commented Jul 19, 2020

Yes @andersk . Thanks. Updated.

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

Successfully merging this pull request may close these issues.

6 participants