Need frame identifier in both browser and renderer process

52 views
Skip to first unread message

Marshall Greenblatt

unread,
Mar 3, 2017, 5:27:28 PM3/3/17
to chromium-dev, John Abd-El-Malek
Hi All,

I need an identifier that consistently points to the same frame in both the browser and renderer process. Prior to [1] (which deleted WebContentsObserver::DidCommitProvisionLoad) I could use the frame routing ID retrieved via RenderFrameHost::GetRoutingID() and RenderFrame::GetRoutingID(). I can no longer use the frame routing ID with DidStartNavigation because, for the main frame, the NavigationHandle state is INITIAL when DidStartNavigation is called and NavigationHandle::GetRenderFrameHost() can't be called at that time (according to DCHECK).

I would in any case prefer to use the frame tree node ID, since that's browser-global and unique, however that doesn't appear to be available in the renderer process.

What is the recommended way to resolve this? Is there a notification other than DidStartNavigation that more closely maps to DidCommitProvisionLoad (e.g. with the RenderFrameHost available)? Or, is there some way to get the frame tree node ID in the renderer process?

Thanks,
Marshall

Chen Zhixiang

unread,
Mar 5, 2017, 5:17:49 AM3/5/17
to Chromium-dev, j...@chromium.org
Hi,

I thought there are 2 kind of id generating mechanism:

(1) Create a unique id, and attach it to object when it's newly created, and use it for its lifelong time
(2) Hashing object's unique attributes such as memory address(this) to get an id

As with (1), also needs IPC to sync browser side with render side, and extra id<-->frame mapping to maintain indexing.

I would prefer (2), even there might be a ABA problem: when a frame is destoryed, and in-place constructed again, the logical 2 frames may share a same hashing id, but it's ok, i guess?

Marshall Greenblatt

unread,
Mar 6, 2017, 1:27:25 PM3/6/17
to chromium-dev, John Abd-El-Malek
On Fri, Mar 3, 2017 at 5:25 PM, Marshall Greenblatt <magree...@gmail.com> wrote:
Hi All,

I need an identifier that consistently points to the same frame in both the browser and renderer process. Prior to [1] (which deleted WebContentsObserver::DidCommitProvisionLoad) I could use the frame routing ID retrieved via RenderFrameHost::GetRoutingID() and RenderFrame::GetRoutingID(). I can no longer use the frame routing ID with DidStartNavigation because, for the main frame, the NavigationHandle state is INITIAL when DidStartNavigation is called and NavigationHandle::GetRenderFrameHost() can't be called at that time (according to DCHECK).

I've been able to work around the lack of RFH in DidStartNavigation by using ReadyToCommitNavigation instead. However, there is still a problem retrieving the RFH in DidFinishNavigation if the navigation is aborted (net_error_code == ERR_ABORTED). In that case DidFinishNavigation will be called with state == WILL_SEND_REQUEST.

From what I can see NavigationHandle does not expose a method for determining if state is >= WILL_PROCESS_RESPONSE (necessary to pass the CHECK in GetRenderFrameHost). How should my code determine if it's safe to call GetRenderFrameHost? I see some other code using (HasCommitted() && !IsErrorPage()), but that appears to miss the (WILL_PROCESS_RESPONSE, DEFERRING_RESPONSE, READY_TO_COMMIT) states where the RFH should also be valid.

Marshall Greenblatt

unread,
Mar 6, 2017, 1:49:50 PM3/6/17
to chromium-dev, John Abd-El-Malek
On Mon, Mar 6, 2017 at 1:25 PM, Marshall Greenblatt <magree...@gmail.com> wrote:
On Fri, Mar 3, 2017 at 5:25 PM, Marshall Greenblatt <magree...@gmail.com> wrote:
Hi All,

I need an identifier that consistently points to the same frame in both the browser and renderer process. Prior to [1] (which deleted WebContentsObserver::DidCommitProvisionLoad) I could use the frame routing ID retrieved via RenderFrameHost::GetRoutingID() and RenderFrame::GetRoutingID(). I can no longer use the frame routing ID with DidStartNavigation because, for the main frame, the NavigationHandle state is INITIAL when DidStartNavigation is called and NavigationHandle::GetRenderFrameHost() can't be called at that time (according to DCHECK).

I've been able to work around the lack of RFH in DidStartNavigation by using ReadyToCommitNavigation instead. However, there is still a problem retrieving the RFH in DidFinishNavigation if the navigation is aborted (net_error_code == ERR_ABORTED). In that case DidFinishNavigation will be called with state == WILL_SEND_REQUEST.

From what I can see NavigationHandle does not expose a method for determining if state is >= WILL_PROCESS_RESPONSE (necessary to pass the CHECK in GetRenderFrameHost). How should my code determine if it's safe to call GetRenderFrameHost? I see some other code using (HasCommitted() && !IsErrorPage()), but that appears to miss the (WILL_PROCESS_RESPONSE, DEFERRING_RESPONSE, READY_TO_COMMIT) states where the RFH should also be valid.

The error arrives via RenderFrameHostImpl::OnDidFailProvisionalLoadWithError, so it should be possible to expose the RFH via NavigationHandle for use from DidFinishNavigation at that time. Can anyone explain the thinking behind not doing so?
Reply all
Reply to author
Forward
0 new messages