ChrisNZL / Fauxbar

An alternative to Chrome's Omnibox.
https://chrome.google.com/webstore/detail/fauxbar/hibkhcnpkakjniplpfblaoikiggkopka
MIT License
89 stars 13 forks source link

Fauxbar crashes in the middle of typing and only works if I restart the plugin #29

Closed BigLep closed 6 years ago

BigLep commented 6 years ago

Hello,

I have been a huge Fauxbar fan and advocate for a couple years. Up until recently (last month) it has worked great. I'm now having issues where in the middle of me typing in the fauxbar it will hang and then fauxbar will no longer work for me unless I restart the extension. I haven't been able to repeatedly come up with a set of actions/keystrokes that triggers this issue, but usually within an hour of me restarting it, the issue happens again. Do you have any suggestions on how I can help debug the issue?

OS: macOS 10.12.6 Chrome: Version 62.0.3202.94 (Official Build) (64-bit) Fauxbar: 1.7.0

Thanks, Steve

ChrisNZL commented 6 years ago

Any errors in Fauxbar's error log? chrome-extension://hibkhcnpkakjniplpfblaoikiggkopka/html/fauxbar.errorlog.html

If not, next time you catch it freezing, I wonder if it would be possible to open Fauxbar's background page and inspect its JavaScript console: Go chrome://extensions and enable Developer mode. Then beside the Fauxbar listing, click the "Inspect views: background page" link and see if the console shows any errors.

You could also try rebuilding Fauxbar's database. Go Fauxbar > Options > Management > "Rebuild" button.

If the whole extension is hanging completely, sounds like the database is getting locked for some reason, so hopefully the error log might have some insight.

BigLep commented 6 years ago

Hi Chris,

Thanks for the response.

  1. There weren't any recent errors in the error log.

  2. Concerning the background page, I only had this error when I first opened a new tab:

Unchecked runtime.lastError while running tabs.get: No tab with id: 1048. at toggleContextMenu (chrome-extension://hibkhcnpkakjniplpfblaoikiggkopka/js/background-new.js:1012:14) at chrome-extension://hibkhcnpkakjniplpfblaoikiggkopka/js/background-new.js:674:32 <chrome-extension://hibkhcnpkakjniplpfblaoikiggkopka/js/background-new.js:674:32>

There were no JS errors when I got the extension to lock up.

  1. Rebuilding unfortunately doesn't help. I cab still type "sag" in my fauxbar and get it to lock up.

Is there anything else I should try?

Thanks a lot, Steve

On Dec 3, 2017, at 12:19 PM, Chris McFarland notifications@github.com wrote:

Any errors in Fauxbar's error log? chrome-extension://hibkhcnpkakjniplpfblaoikiggkopka/html/fauxbar.errorlog.html

If not, next time you catch it freezing, I wonder if it would be possible to open Fauxbar's background page and inspect its JavaScript console: Go chrome://extensions and enable Developer mode. Then beside the Fauxbar listing, click the "Inspect views: background page" link and see if the console shows any errors.

You could also try rebuilding Fauxbar's database. Go Fauxbar > Options > Management > "Rebuild" button.

If the whole extension is hanging completely, sounds like the database is getting locked for some reason, so hopefully the error log might have some insight.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ChrisNZL/Fauxbar/issues/29#issuecomment-348811204, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFNo5WPQ2xAMrf-1TrVo0QobBvWNr4Qks5s8wJegaJpZM4Qzm8R.

ChrisNZL commented 6 years ago

Hmm k. (that "No tab with id" error is a long-standing non-issue, something to do with the way Chrome pre-loads URLs, I haven't found a way to suppress it)

On the Fauxbar tab when you type in your query, can you please open Chrome's developer tools (Cmd+Option+I) and open the Console before typing in sag... does anything appear in the console there as you type?

So the behaviour is the whole tab feezes? Can no longer click on things in the Fauxbar tab; the page freezes and becomes unresponsive? And once it freezes, opening new Fauxbar tabs still doesn't work, you have to restart the extension?

Without errors there is not much I can do on my end. sag returns results okay for me, I haven't been able to reproduce this with my data.

At a guess:

There's been issues in the past where "data blob" URLs were extremely long using the data: scheme (like when 2 MB of image data is crammed into a blob URL using base64 encoding; Fauxbar and/or SQLite doesn't really enjoy parsing large strings of binary data. I have a check in place to exclude such URLs from being added to the database, but I am wondering if perhaps there is a new similar data scheme that's letting in some super big URL string into the database.

My code also has a check in place to delete URLs that start with javascript: so maybe there's a similar non-http: scheme that is causing the issue.


Debugging - JavaScript console

Assuming it is a really long URL that is the culprit, or something that is not using http, I would hunt for such a URL.

You could print a list of URLs matching sag. In a Fauxbar tab, open Chrome's Developer tools, Console tab. Paste in:

if (openDb()) {
    window.db.transaction(function(tx){
        tx.executeSql('SELECT url FROM urls WHERE url LIKE ?', ["%sag%"], function(tx, results){
            for (var i = 0; i < results.rows.length; i++) {
                var row = results.rows.item(i);
                console.log(row.url);
            }
        });
    });
}

See if any URLs are too long or any not using http. If you're not sure, you could right-click the log, go Save As, and email me the log if you're comfortable with that.


Debugging - Opening SQLite file externally

If attempting to perform the above query causes a freeze, you could open the SQLite database file directly using DB Browser for SQLite.

On macOS, Fauxbar's SQLite database directory should be:

~/Library/Application Support/Google/Chrome/Default/databases/chrome-extension_hibkhcnpkakjniplpfblaoikiggkopka_0/

and within the folder should be a single file named 1 - this is Fauxbar's SQLite database. Probably best to quit Chrome before trying to access it.

Open the 1 file with DB Browser, click the "Execute SQL" tab, and paste in:

SELECT url FROM urls WHERE url LIKE "%sag%"

and it will show a scrollable box of rows, so you could look for culprit URLs.


If you'd rather me take a full look, you could email me your Fauxbar SQLite database (the 1 file) and I can try to reproduce this. Note that this will include all your URLs, though I'd only use it to try and reproduce this issue.

Other than that, I really don't know. You could try creating a new Chrome profile, or clearing Chrome's history and rebuilding Fauxbar again (though if a bookmark is the culprit, then we need to find the culprit bookmark), even uninstall Fauxbar completely and reinstall. If there's an actual error somewhere, I can hopefully take action, otherwise I'm just grasping at straws without data in front of me.

BigLep commented 6 years ago

Hi Chris,

No pressure/expectation to respond, but wanted to make sure I emailed you more information privately. Just posting in the public forum in case my private email didn't go through.

Thanks, Steve

On Dec 4, 2017, at 3:30 PM, Chris McFarland notifications@github.com wrote:

Hmm k. (that "No tab with id" error is a long-standing non-issue, something to do with the way Chrome pre-loads URLs, I haven't found a way to suppress it)

On the Fauxbar tab when you type in your query, can you please open Chrome's developer tools (Cmd+Option+I) and open the Console before typing in sag... does anything appear in the console there as you type?

So the behaviour is the whole tab feezes? Can no longer click on things in the Fauxbar tab; the page freezes and becomes unresponsive? And once it freezes, opening new Fauxbar tabs still doesn't work, you have to restart the extension?

Without errors there is not much I can do on my end. sag returns results okay for me, I haven't been able to reproduce this with my data.

At a guess:

The SQLite database has an issue with one or more rows, or Fauxbar's JavaScript has an infinite loop somewhere. There's been issues in the past where "data blob" URLs were extremely long using the data: scheme (like when 2 MB of image data is crammed into a blob URL using base64 encoding; Fauxbar and/or SQLite doesn't really enjoy parsing a large strings of binary data. I have a check in place to exclude such URLs from being added to the database, but I am wondering if perhaps there is a new similar data scheme that's let in some super big URL string into the database.

My code also has a check in place to delete URLs that start with javascript: so maybe there's a similar non-http: scheme that is causing the issue.

Debugging - JavaScript console

Assuming it is a really long URL that is the culprit, or something that is not using http, I would hunt for such a URL.

You could print a list of URLs matching sag. In a Fauxbar tab, open Chrome's Developer tools, Console tab. Paste in:

if (openDb()) { window.db.transaction(function(tx){ tx.executeSql('SELECT url FROM urls WHERE url LIKE ?', ["%sag%"], function(tx, results){ for (var i = 0; i < results.rows.length; i++) { var row = results.rows.item(i); console.log(row.url); } }); }); } See if any URLs are too long or any not using http. If you're not sure, you could right-click the log, go Save As, and email me mailto:chris@mcfarland.co.nz the log if you're comfortable with that.

Debugging - Opening SQLite file externally

If attempting to perform the above query causes a freeze, you could open the SQLite database file directly using DB Browser for SQLite http://sqlitebrowser.org/.

On macOS, Fauxbar's SQLite database directory should be:

~/Library/Application Support/Google/Chrome/Default/databases/chrome-extension_hibkhcnpkakjniplpfblaoikiggkopka_0/ and within the folder should be a single file named 1 - this is Fauxbar's SQLite database. Probably best to quit Chrome before trying to access it.

Open the 1 file with DB Browser, click the "Execute SQL" tab, and paste in:

SELECT url FROM urls WHERE url LIKE "%sag%" and it will show a scrollable box of rows, so you could look for culprit URLs.

If you'd rather me take a full look, you could email me mailto:chris@mcfarland.co.nz your Fauxbar SQLite database (the 1 file) and I can try to reproduce this. Note that this will include all your URLs, though I'd only use it to try and reproduce this issue.

Other than that, I really don't know. You could try creating a new Chrome profile, or clearing Chrome's history and rebuilding Fauxbar again (though if a bookmark is the culprit, then we need to find the culprit bookmark), even uninstall Fauxbar completely and reinstall. If there's an actual error somewhere, I can hopefully take action, otherwise I'm just grasping at straws without data in front of me.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ChrisNZL/Fauxbar/issues/29#issuecomment-349142704, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFNo3QAXCTdMadS6K-GiuXMyJ5A88h2ks5s9ICugaJpZM4Qzm8R.

ChrisNZL commented 6 years ago

Hi, yes I've received your email thanks, on my todo list to investigate it. With 2 kids and work and other stuff, just haven't had time to be in the right mindset to try the next step. Is on my list though.

BigLep commented 6 years ago

Hi Chris,

Thanks a lot and I 100% understand. No worries, and let me know if/how can help more.

Steve

On Dec 10, 2017, at 10:08 PM, Chris McFarland notifications@github.com wrote:

Hi, yes I've received your email thanks, on my todo list to investigate it. With 2 kids and work and other stuff, just haven't had time to be in the right mindset to try the next step. Is on my list though.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ChrisNZL/Fauxbar/issues/29#issuecomment-350630981, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFNo48ygHmE8KnpfVjRVux6ADFrpobCks5s_MbvgaJpZM4Qzm8R.

ChrisNZL commented 6 years ago

Hi Steve, working on looking at this, but not much luck on my end.

I tried creating a 5,000-character-long URL with mixed casing of a-zA-Z0-9 but Fauxbar handled it fine, so URL length probably isn't the issue here.

Looking at your processes sample file, assuming Fauxbar's stuff is managed by Google Chrome Helper and/or Google Chrome Framework (there's no specific reference to Fauxbar anywhere so I'm just guessing here), there's a lot of calls to pthread_mutex_lock and it doesn't look like the last reference to it gets unlocked...

When typing in Fauxbar's Address Box, Fauxbar doesn't call any chrome APIs, just interacts with the WebSQL API...

I'd guess the WebSQL database file gets locked but does not become unlocked, so the extension hangs. (or Chrome is locking something else, but I don't know what) Which is weird, because from my experience, if the WebSQL file is locked, Fauxbar will just "wait" for the query to finish, while still letting the rest of the extension remain usable (like for clicking Fauxbar's menubar). And Fauxbar doesn't access its background page when typing into Fauxbar's Address Box, but you say the whole extension freezes and unable to use new Fauxbar tabs, so 🤔 hmm hmm...

Something to try: In Fauxbar's Address Box, paste in: sag is:fav This will limit to only search rows that are marked as bookmarks. (just to maybe narrow it down if the supposed culprit URL is a bookmark or not)


If I could please request further information from you: Do any of the URLs returned when you search for %sag% in the JavaScript console SELECT query (from my earlier post) contain non-alphanumeric characters, or characters not typically found in a URL? (like characters that aren't / # ? = : &) While in theory I don't expect it's the issue, just makes me wonder.

Wanting to respect your privacy as much as possible, would you be willing to supply your URLs to me that match %sag%, but redact the domain from each URL? and/or feel free to redact sensitive parts from the URL if absolutely needed, really I'm just looking for obscure characters or symbols that might be causing the issue.

In theory it shouldn't matter since Fauxbar is just performing a string-based search, but I'm really out of other ideas if all the %sag% URLs start with http. I really need URL data to try and reproduce this.

ChrisNZL commented 6 years ago

Oh, just thought, it's also possible the culprit row's title column could contain the issue.

Perhaps try running this JavaScript code in a Fauxbar tab's console for more comprehensive results:

if (openDb()) {
    window.db.transaction(function(tx){
        tx.executeSql('SELECT title, url FROM urls WHERE title LIKE ? OR url LIKE ?', ["%sag%", "%sag%"], function(tx, results){
            for (var i = 0; i < results.rows.length; i++) {
                var row = results.rows.item(i);
                console.log(row.title + "\n" + row.url);
            }
        });
    });
}
ChrisNZL commented 6 years ago

Another thing to try, if it's feasible... If there aren't too many results matching sag, and if you felt up to it, from the console query above, copy and paste each URL and/or title one by one into Fauxbar's Address Box, to try figure out which result in particular is the bad one.

BigLep commented 6 years ago

Hi Chris,

I believe I have found the culprit URLs. I'll send them to your privately. They are URLs that have a JSON object embedded as a query parameter.

Steve

On Dec 11, 2017, at 5:28 PM, Chris McFarland notifications@github.com wrote:

Another thing to try, if it's feasible... If there aren't too many results matching sag, and if you felt up to it, from the console query above, copy and paste each URL and/or title one by one into Fauxbar's Address Box, to try figure out which result in particular is the bad one.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ChrisNZL/Fauxbar/issues/29#issuecomment-350915127, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFNo_1Z4qmysVxSTnBKKQ3lirIhzNqZks5s_dbEgaJpZM4Qzm8R.

ChrisNZL commented 6 years ago

Thanks for sending those through, I can reproduce this issue now. Your first URL does the trick. For me, Fauxbar in its entirety freezes for about one minute, but eventually throws a JavaScript error like:

Uncaught Syntax error, unrecognized expression: [\n \"foo:bar\"\n ]
js/jquery-1.7.min.js, line 3

and the trace points to fauxbar-1.js, line 2783:

if (resultIsOkay && $('.result[url="'+hI.url+'"]').length > 0) {

hI.url is the history item's URL in this case. .result is one of the rows on the divs that are appended below the Address Box, each with a url attribute that has its URL as the value. I believe the issue is jQuery is trying to find the element in the DOM, but must be getting caught up with the JSON brackets, newlines, or quotes, or something. Might be trying to do a deep DOM search with the amount of brackets your URL/JSON object has too.

I tried quickly to make a small test reproducible URL to mimic your JSON URL to trigger this issue but haven't had luck yet, I need delve further. Will look into this more soon.

In the meantime, if you go Fauxbar > Options > Address Box > Results, there is a "Don't show results from" field that lets you exclude URLs from showing, thus circumventing the issue for now if desired.

BigLep commented 6 years ago

@ChrisNZL : thanks again for the help here. The workaround of excluding the problematic URLs has worked great. Good stuff!

ChrisNZL commented 6 years ago

It seems that having quotes in an anchor triggers the issue. Semi-inconsistent. Does not affect the main part of a URL since " gets encoded into %23, but past the anchor # part, " retains as a quote.

In its simplest form, it's a syntax error:

Uncaught Syntax error, unrecognized expression: url="http://localhost/#""]

An odd number of quotes throws an error, while an even number of quotes does not:

http://localhost/#"   <--- triggers an error
http://localhost/#""  <--- is fine

However, once you start mixing escaped quotes with non-escaped quotes, the logic seems to break; odd or even quotes doesn't seem to follow a pattern:

http://localhost/#\""        <--- 1 not escaped, 1 escaped, is fine
http://localhost/#"\"        <--- 1 not escaped, 1 escaped, is fine (reversed order)
http://localhost/#\"\"       <--- 2 escaped, is fine
http://localhost/#\"\"\"     <--- 3 escaped, is fine
http://localhost/#\"\""      <--- 1 not escaped, 2 escaped, breaks
http://localhost/#\"\"""     <--- 2 not escaped, 2 escaped, is fine
http://localhost/#\"\""""    <--- 3 not escaped, 2 escaped, breaks
http://localhost/#\""\"\""   <--- 2 not escaped, 3 escaped, breaks
http://localhost/#\""\"\"""  <--- 3 not escaped, 3 escaped, is fine

Solutions for me to try:

ChrisNZL commented 6 years ago

Fixed now for v1.7.3. Ended up replacing " with &quot; after pulling from the database, so attribute and href lookups no longer conflict with HTML quotes. Thanks for your help.