Can't change variable in Chrome Developer Tools Console - google-chrome

I used to be able to put a break point in a javascript function and change variable values to debug. This worked until recently (within a week or two).
Here's an example:
function test(params) {
var result = params.num * 2;
// if I put a break point here and change result = undefined,
// it doesn't work
return result;
}
// I should get 6, but when debugging and changing result to undefined,
// I should get undefined in my output, used to, not anymore
var x = test({ num: 3 });
console.log(x);
I'm using OSX Yosemite Chrome v. 49.0.2623.110 (64-bit)
It is up to date and I just restarted Chrome.
I do this all the time, but something happened recently and I can't anymore. Any help would be greatly appreciated.
Thanks

It looks like this was documented behavior for a while. Just yesterday a change was made to the code that says it will restore the ability to change variables. It is very disappointing that they allowed it to break for any length of time.
https://bugs.chromium.org/p/chromium/issues/detail?id=569811&q=debugger%20change%20variable&colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified

Related

Visual Studio sorting JSON properties wrong

I've run into a weird problem with Visual Studio 2017 (Enterprise, version 15.5.2) that I can only replicate on one specific machine. The problem doesn't occur on other development machines.
Given a file foo.resources.json with the following contents:
{
"FooReparatur": "Reparatur",
"FooVerlust": "Verlust",
"FooWema": "Wema"
}
Applying the quick action Sort Properties results in the keys being in the wrong order:
{
"FooReparatur": "Reparatur",
"FooWema": "Wema",
"FooVerlust": "Verlust"
}
The configured language for Visual Studio is English, there is no schema selected for the given file. The configured language for Windows is Estonian, but the sorting order is wrong by that alphabet as well.
I checked for any funny unicode characters or anything similar via a hexdump, but found nothing of the like either. As mentioned before, the file sorts correctly on all other machines.
I've tried disabling all the (default) extensions the installation has, but that doesn't resolve the problem either.
I've looked through most of the settings for both general text editing and the specific file type, but I can't find a setting that could cause this. What could be the issue? How can I debug this further?
This is a property of Estonian collation where 'V' and 'W' are treated as the same character. Hence, the next character that differs will be the significant one. As can be demonstrated by this C# code using .Net.
var words1 = new[] { "FooR", "FooVer", "FooWem" };
var words2 = new[] { "FooR", "FooVa", "FooWb" };
var estonianCultureInfo = new System.Globalization.CultureInfo("et-EE");
var estonianComparer = StringComparer.Create(estonianCultureInfo, false);
var sortedWords = words1.OrderBy(x => x, estonianComparer);
foreach (var word in sortedWords)
{
Console.WriteLine(word);
}
Console.WriteLine("[-----]");
sortedWords = words2.OrderBy(x => x, estonianComparer);
foreach (var word in sortedWords)
{
Console.WriteLine(word);
}
Output:
FooR
FooWem
FooVer
[-----]
FooR
FooVa
FooWb
Try to use this plugin to sort :
https://marketplace.visualstudio.com/items?itemName=richie5um2.vscode-sort-json
If dosn't work, try to install again the visual studio and choose language English to test if it work
Good Chance.

Code crashes, but only in Debug mode

The following code works perfectly if run normally
function initialPopulation()
{
var group = ContactsApp.getContactGroup('clients');
var myContacts = ContactsApp.getContactsByGroup(group);
for (var i=0;i<myContacts.length;i++)
{
var row = i+1;
var getPrimaryEmail = myContacts[i].getPrimaryEmail();
ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss.getRange("A"+row).setValue(getPrimaryEmail);
var temp=0;
}
}
If I debug the code, without any stops, it also runs perfectly without issues.
However, if I try to debug the code, with a stop on the line "temp=0", then continue to debug, it will always crash:
We're sorry, a server error occurred. Please wait a bit and try again.
(line 10, file "Code")
Line 10 is:
var getPrimaryEmail = myContacts[i].getPrimaryEmail();
Any ideas what could be happening?
This is driving me crazy because I cannot debug more complex code.
I can confirm this, even in an older script that I am fairly certain I have previously single-stepped through. What a show-stopper.
Further, you can reproduce the same error with .contact.getEmails(), so my bet is that a bug has been introduced. No sign of it on the issue tracker, unless you count Issue 5502.
I recommend raising a new issue. (Done: Issue 5515.)
In the mean time, you can work around the problem by NOT single stepping over methods like this one that the debugger can't unspool. That means that you cannot have any breakpoints BEFORE the fatal line, as it will die on continuation.

Get Current Location Instantly

I am using the following code to request current location:
private void RequestCurrentLocation()
{
Criteria locationCriteria = new Criteria () { Accuracy = Accuracy.NoRequirement, PowerRequirement = Power.NoRequirement };
this.mgr = GetSystemService (Context.LocationService) as LocationManager;
String locationProvider = this.mgr.GetBestProvider (locationCriteria, true);
this.mgr.RequestLocationUpdates (locationProvider, 0, 0, this);
}
As I need location only once, so I call RemoveUpdates() as soon as OnLocationChanged is raised and then carry on with rest of the working:
public void OnLocationChanged (Location location)
{
this.mgr.RemoveUpdates (this);
//Rest of the method
}
I face two issues:
1) Although I have provided zero in the distance and time parameters of RequestLocationUpdates but it still needs at least 2-3 seconds before the OnLocationChanged is triggered. How can I make it instantaneous?
2) I intermittently face the issue that the OnLocationChanged event does not fire at all. Yesterday I spent the whole day to get my code working which was flawlessly working a day earlier. It's really strange that something works properly one day and the next day it simply stops even with the very same source code! Can somebody give me an idea?
Thanks.
There's no way to get an accurate, up-to-date location instantly.
For a device to determine location it needs to track GPS, WiFi, 3G towers and that depends on radio signal strength, transmission speed and other little stuff like that. You can trick the parameters of your request to try to have a faster update (for example, instead of best provider, try to use any provider available).
As a alternative approach you can request to getLastKnownLocation, this method is synchronous and replies instantly with the last location that the system found. The issue is that the "last known location" might be null (if the system never found any location), or might be very old (if the last location was days ago).

jqGrid.GetRowData with Id from double click throwing exception

I have a work flow...
ondblClickRow: function (id) {
debugger;
var rowData = $("#list").getRowData(id);
...
}
This function call is throwing an exception whereas it previously worked. Actually stepping into the mini-fied code I can see that there is an array out of bounds exception of sorts. There are only seven columns and it appears to be calling an eighth (zero indexed-I have columns from 0-6, and it appears to be asking for a seventh). Not sure what is going on in that particular exception. I am still researching, but this was working fine and I did not change anything related to this in weeks. AM I missing something here?
This is kind of a hack work around, but I simply just got the cell values that I needed based on the id and the column names that I needed so I could circumvent any issue that might be occuring... Even though I am not sure what happened. I am still very curious as to why this occured. More research will need to be done for me to be more comfortable with this solution...
var FName = $('#list').getCell(id, 'First_Name');

HTML5 Gamepad API on Chrome

I'm using Chrome (Version 19.0.1084.46). I enabled the Gamepad API in chrome://flags. I plugged in some game pads, but navigator.webkitGamepads is always an array of length 4 containing only undefined.
navigator.webkitGamepads
GamepadList
0: undefined
1: undefined
2: undefined
3: undefined
length: 4
__proto__: GamepadList
What do I need to do to test out using gamepads? I'm on Ubuntu Linux if that matters.
I was having trouble with this as well (on Ubuntu 10.04 with Chrome 21.0.1163.0 dev). I ran across this from a thread on chromium-discussions:
Note that you need to press a face button on the gamepad before data
will be available. This is due to fingerprinting concerns.
I wrote a quick test page that seems to work if you hold a controller button down while refreshing the page. I'm using a Gamestop-branded Xbox 360 wired controller with the xboxdrv driver.
Also, one other important thing to note - Chrome treats these Gamepad objects like snapshots of the controller state. So if you pass around the actual Gamepad object, you'll never get updated information. Chrome seems to only poll the controller when you call the navigator.webkitGamepads[x] getter (see line 23 in my test page).
SPECIAL NOTE: The GamePad API is handled in two completely different ways by Firefox and Google Chrome. Because of this, you need to include code to test for your browser's identity, and handle the cases accordingly.
When the navigator.getGamePads() method is invoked, an array of objects is returned, and those objects contain information about the identity of your gamepads/joysticks, and the state of the axes/buttons thereof.
Here's the issue: on Firefox, the method hands the array to your calling code, and you can then examine that array repeatedly, to look for changes of axis/button state in your own code. Firefox behaves in the expected manner, and updates the objects you've received with new axis/button data, as and when it becomes available.
Google Chrome, on the other hand, treats the array totally differently. Chrome treats the array as a one-time snapshot of the status of your gamepads/joysticks, and if you want to fetch new data, you have to perform another invocation of navigator.getGamePads(), to fetch a new snapshot, discarding the old one.
As a consequence, you need something like this to make your code work on both browsers (assuming that the variable 'gp' is the variable in which you previously stored the return value from your first invocation of navigator.getGamePads() ...)
var ua = navigator.userAgent;
if (ua.toLowerCase().indexOf("chrome") != -1)
gp = navigator.getGamePads();
Why the two browsers behave so differently, is a topic for another thread, but I suspect it has much to do with the fact that the GamePad API is still somewhat experimental, and the fine detail of the standard applicable thereto has not yet been finalised.
In my case, running Chrome on Windows 7 64-bit (but the 32-bit version, for some strange reason best known to my computer's manufacturer, who installed it in this fashion), the array returned by navigator.getGamePads() currently contains only as many entries as there are actual gamepads/joysticks plugged into my computer. If you're experiencing something different on Chrome under Linux, then you need to take this into account also, by testing to see if you have any null values in the array.
Another factor to take into account, is that when selecting a gamepad/joystick, the standard in place calls for the index property of the GamePad object to be referenced, and used thereafter to index into the array. The reason for this is covered in more detail in this document:
W3C page : Editor's Draft on the GamePad interface
However, whilst the implementation of this works as documented above in my incarnation of Google Chrome, you may have to check your version experimentally to see if it behaves the same as mine. If it doesn't, adjust your code accordingly until such time as the standard is finalised, and proper conformity thereto is enforced in all modern browsers and all OS incarnations thereof.
So, when you're selecting a particular gamepad/joystick to work with, the code will look something like this (with the variable 'gid' as your index selector):
var gLen = this.gamePads.length;
done = false;
idx = 0;
while (!done)
{
if (this.gamePads[idx] !== null)
{
if (gid == this.gamePads[idx].index)
{
//Here, choose this GamePad as the selected GamePad, based upon the index number as per the W3C recommendation ...
selectedGamePadIndex = gid;
selectedGamePad = this.gamePads[idx];
done = true;
//End if
}
//End if
}
//Update counter in case we haven't selected one of the available GamePads above ...
idx++;
if (idx >= gLen)
done = true; //Exit loop altogether if we've exhausted the list of available GamePads
//End while
}
I actually implemented the above code (along with some tidying up at the end) as a method for a custom object, but the principle remains the same regardless of the implementation minutiae. (I'll confess at this juncture that I have a habit of writing my own short libraries to handle tasks like this!)
Another issue to watch out for, is the manner in which the gamepad API maps the physical data sources of your gamepad/joystick to the axis/button elements of the GamePad object, and the values contained therein. I have a Microsoft Sidewinder Pro USB joystick, and the mappings for this device on my computer are seriously weird, viz:
Axes 0/1: Joystick handle (as expected)
Axes 2/3: Not assigned
Axes 4/5: 4 not assigned, 5 assigned to twist grip
Axes 6/7: 6 assigned to round slider, 7 not assigned
Axes 8/9: 8 not assigned, 9 assigned to hat switch (er, WHAT???)
Yes, that's right, analogue axis 9 is assigned to the hat switch, and seriously odd values are returned, viz:
Hat switch centred: +1.2
Hat switch up: -1.0
Hat switch down: +0.1
Hat switch left: +0.7
Hat switch right: -0.42
Quirks like this are something you should be alert to as you experiment with the GamePad API. Even worse, a so-called "standard" GamePad (defined in that document I linked to above) may report as standard on some browsers, but not on others, or worse still, report as standard on browser X in Windows, but not on the same browser X in Linux! While this will induce much hair-tearing frustration as you try to fight your way through this software equivalent of bramble thicket, getting badly scratched by some of the thorns along the way, you can at least take comfort in the fact that browser developers are working to try and ameliorate this, but it'll take time, because other things take priority (such as making sure your browser doesn't become an easy target for ransomware to hijack, which will ruin you day immensely if it happens).
This didn't work for me but maybe it helps you? Pulled from here.
function updateStatus() {
window.webkitRequestAnimationFrame(updateStatus);
var gamepads = navigator.webkitGamepads;
var data = '';
for (var padindex = 0; padindex < gamepads.length; ++padindex)
{
var pad = gamepads[padindex];
if (!pad) continue;
data += '<pre>' + pad.index + ": " + pad.id + "<br/>";
for (var i = 0; i < pad.buttons.length; ++i)
data += "button" + i + ": " + pad.buttons[i] + "<br/>";
for (var i = 0; i < pad.axes.length; ++i)
data += "axis" + i + ": " + pad.axes[i] + "<br/>";
}
document.body.innerHTML = data;
}
window.webkitRequestAnimationFrame(updateStatus);
Or as a hard alternative, there's the Javascript Joystick Plug-in (demo here) but I don't think that works in Linux.