RESOLVED FIXED 29924
Database Inspector crashes Safari when table has more than 21 columns
https://bugs.webkit.org/show_bug.cgi?id=29924
Summary Database Inspector crashes Safari when table has more than 21 columns
Tim Lind
Reported 2009-09-30 07:29:16 PDT
Create a table with 21 or more columns. Select it under the database in the Web Inspector, and Safari hangs (infinitely).
Attachments
test case (789 bytes, text/html)
2009-09-30 12:35 PDT, Tim Lind
no flags
[PATCH] Fix Hang (7.68 KB, patch)
2009-09-30 21:20 PDT, Joseph Pecoraro
timothy: review-
[PATCH] Fix Hang (1.73 KB, patch)
2009-10-02 12:52 PDT, Joseph Pecoraro
timothy: review+
Patrick Mueller
Comment 1 2009-09-30 11:32:29 PDT
Here's an example that creates exactly 21 columns which does not appear to hang Safari when viewing the db in Web Inspector in nightly r48908. Reloading the page over and over will result in a new row being added each time. I wonder if it's some data that's causing a problem? Why do you think it's the 21st column that causes a problem? ---------- clip here ---------- <script> var db = openDatabase("bug-29924", "1.0", "sample for webkit bug 29924", 200000); var cols21def = ""; var cols21spec = ""; var vals21spec = ""; var vals21 = [] for (var i = 1; i <= 21; ++i) { cols21def = cols21def + "col" + i + " TEXT"; cols21spec = cols21spec + "col" + i; vals21spec = vals21spec + "?"; vals21.push(new Date().toString()); if (i != 21) { cols21def += ", "; cols21spec += ", "; vals21spec += ", "; } } db.transaction(function(tx) { var statement = "CREATE TABLE IF NOT EXISTS TwentyOneColumns (" + cols21def + ")"; tx.executeSql( statement, [], function(tx, result) { var statement = "INSERT INTO TwentyOneColumns (" + cols21spec + ") VALUES (" + vals21spec + ")"; tx.executeSql( statement, vals21, function(tx, result) {}, function(tx, error) { alert("Error during INSERT: " + JSON.stringify(error)); } ); }, function(tx, error) { alert("Error during CREATE TABLE: " + JSON.stringify(error)); } ); }); </script> ---------- clip here ----------
Tim Lind
Comment 2 2009-09-30 12:35:21 PDT
Created attachment 40391 [details] test case 21 columns, with one unique constraint on two of the columns.
Tim Lind
Comment 3 2009-09-30 12:37:37 PDT
Your code didn't cause any problems for me either. I tried adding a one key unique constraint to yours and it was still fine. The file I attached now shows the problem. It has one unique constraint on two columns. Inserts undefined values for some columns. The problem only occurs once data is inserted that can be viewed. Taking one column away should fix the problem. Enjoy.
Patrick Mueller
Comment 4 2009-09-30 14:00:11 PDT
Great. That test does result in nightly hanging, sitting at nearly 100% cpu. Should be fun to debug :-(
Joseph Pecoraro
Comment 5 2009-09-30 20:57:16 PDT
(In reply to comment #4) > Great. That test does result in nightly hanging, sitting at nearly 100% cpu. > Should be fun to debug :-( I've had some experience working with the DataGrids so the number 21 jumped out at me immediately. The "minimum" size of each column was set at 5%, and in Storage.js dataGridForResult. There is a section where it will continue to "adjust" the columns not willing to go less then their minimum in order to fit into 100%. Great spot for an infinite loop. Patch to come soon.
Joseph Pecoraro
Comment 6 2009-09-30 21:20:21 PDT
Created attachment 40420 [details] [PATCH] Fix Hang Since I moved the DataGrid creation code into its view (like DOM Storage and Cookies did and are unaffected due to fixed/known number of columns) its hard to see the explicit changes, so I'll mention them here. Changes: - numColumns variable to count the number of columns - const minimumPrecent = Math.min(5, Math.floor(100/numColumns)); The Math.floor is not really necessary but working with integer values seemed better then having horrible percentages like "4.761904761904762". I don't think we should worry about the unrealistic case of >100 columns, causing the minimumPercent to floor to 0. The grid could not be useful, but at least it wouldn't crash.
Timothy Hatcher
Comment 7 2009-10-02 12:43:10 PDT
Comment on attachment 40420 [details] [PATCH] Fix Hang DatabaseQueryView.js uses dataGridForResult. So we shouldn't move it yet.
Joseph Pecoraro
Comment 8 2009-10-02 12:52:40 PDT
Created attachment 40542 [details] [PATCH] Fix Hang Good Catch. Fixed.
Joseph Pecoraro
Comment 9 2009-10-02 13:11:08 PDT
Committed in http://trac.webkit.org/changeset/49039 M WebCore/ChangeLog M WebCore/inspector/front-end/StoragePanel.js r49039 = 9b3be88c052ba7e1b9c6a78f125d1a6222530cf7 (trunk)
Note You need to log in before you can comment on or make changes to this bug.