Closed
Bug 492312
Opened 16 years ago
Closed 16 years ago
DocumentLoaded() called multiple times loading one page
Categories
(Core Graveyard :: Embedding: APIs, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: huixue.uiuc, Assigned: bzbarsky)
Details
(Keywords: topembed, Whiteboard: How to know a page is totally finished load+rendering?)
Attachments
(1 file)
2.48 KB,
patch
|
mfinkle
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Chrome/1.0.154.59 Safari/525.19
Build Identifier: change set 117:0567bf985e06, Thu Mar 26 00:48:30 2009 -0500
I am trying to figure out how to know one page is "totally"
loaded. I tried the DocumentLoaded() function, but it is called
multiple times when loading one page. My guess: it is called whenever
one iframe is finished loading.
SYMPTOM: Try this web site: www.sina.com.cn and DocumentLoaded
() will be called multiple times.
QUESTION: how to know one page is "totally" loaded?
DETAILS ABOUT WHAT I DID:
I am using the "mozembed" from this page: https://wiki.mozilla.org/Embedding/NewApi#Getting_the_code
in /mozembed/gtk/tests/test.cpp,
I added
g_signal_connect(view,"document_loaded",G_CALLBACK
(my_loaded),view);
to "add_page()" function:
==================================================
GtkWidget *
add_page(GtkNotebook *notebook)
{
GtkWidget *view = moz_web_view_new();
GtkWidget *box = gtk_hbox_new(FALSE, 5);
GtkWidget *tab_label = gtk_label_new("Loading...");
GtkWidget *close_button = gtk_button_new();
gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
GtkWidget *close = gtk_image_new_from_stock(GTK_STOCK_CLOSE,
GTK_ICON_SIZE_MENU);
gtk_container_add(GTK_CONTAINER(close_button), close);
gtk_box_pack_start(GTK_BOX(box), tab_label, TRUE, TRUE, 0);
gtk_box_pack_end(GTK_BOX(box), close_button, FALSE, FALSE, 0);
gtk_widget_show_all(box);
gtk_widget_show(view);
g_signal_connect(view, "title-changed", G_CALLBACK(title_cb),
tab_label);
g_signal_connect(view, "location-changed", G_CALLBACK
(location_cb), NULL);
g_signal_connect(view, "status-changed", G_CALLBACK(status_cb),
NULL);
g_signal_connect(close_button, "clicked", G_CALLBACK(close_cb),
view);
////////////////Hui
g_signal_connect(view,"document_loaded",G_CALLBACK
(my_loaded),view);
////////////////Hui
moz_web_view_load_uri(MOZ_WEB_VIEW(view), "http://
www.google.com");
int page = gtk_notebook_append_page(notebook, view, box);
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), page);
return view;
}
===================================================
where "my_loaded" is the function I am calling whenever after
DocumentLoaded() is called.
In this way, I detected DocumentLoaded() called multiple times when I
am loading www.sina.com.cn by simply printing out something in
"my_loaded()", actually it is called seven times, corresponding to
seven iframes in that web page.
Your help is deeply appreciated.
Reproducible: Always
Steps to Reproduce:
1. add g_signal_connect(view,"document_loaded",G_CALLBACK
(my_loaded),view);
into "add_page(GtkNotebook*)" function, I have described how to do this in "details". (or you can simply print something out in DocumentLoaded() function in Moz-web-view.cpp)
2. load www.sina.com.cn
3. watch how many times DocumentLoaded() get called.
Actual Results:
about 15 times.(guess it is called for each iframe)
Expected Results:
should be only 1 time.
Struggling to know WHEN the page is totally loaded AND rendered. Seems to be a hard question to answer.
In MS Trident, the same problem could be bypassed by figuring out who is calling the callback, if the top level window, should be really finished, otherwise should not be finished yet.
Keywords: topembed
Whiteboard: How to know a page is totally finished load+rendering?
![]() |
Assignee | |
Comment 1•16 years ago
|
||
mfinkle, looks like this code has been around since rev 6524d040e08f in incubator-central. The code for DocumentLoaded is fundamentally broken; as hui xue guesses it will call the callback for every single subframe, possibly multiple times for a given subframe during a single toplevel document load. And it doesn't give the callee the information needed to tell _what_ has loaded.
Basically, this callback is completely useless as it stands.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: blocking1.9.2?
Updated•16 years ago
|
Flags: wanted-fennec1.0?
Comment 3•16 years ago
|
||
Is there a standards issue here or just embedding?
![]() |
Assignee | |
Comment 4•16 years ago
|
||
This is a pure "our embedding api is not usable" issue.
![]() |
Assignee | |
Comment 5•16 years ago
|
||
I have no idea how to compile and test this, sadly... the incubator repo seems to have nothing like makefiles and such in it.
Attachment #381458 -
Flags: review?(mark.finkle)
Comment 6•16 years ago
|
||
Tested via projects. Before/after tests show this does fix the problem:
http://hg.mozilla.org/incubator/embedding/rev/c335c76103d5
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Comment 7•16 years ago
|
||
Comment on attachment 381458 [details] [diff] [review]
This should fix it
forgot to actually flip this
Attachment #381458 -
Flags: review?(mark.finkle) → review+
Updated•16 years ago
|
Flags: wanted-fennec1.0?
Flags: blocking1.9.2?
Flags: blocking1.9.2-
Updated•14 years ago
|
Assignee: nobody → bzbarsky
Updated•6 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•