This looks like a VM bug.
Please verify with the latest version if the problem still persists, and file a bug otherwise (http://dartbug.com/new).
thanks!
Pergunta
I calculate random colors for my application. They are in rgba format and i have tested various versions for coloring. Right now i want fully opaque cubes but as that may change i have implemented coloring like this:
int r = rnd.nextInt(255);
int g = rnd.nextInt(255);
int b = rnd.nextInt(255);
int a = 255;
int color = (r & 0xFF) | ((g & 0xFF) << 8) | ((b & 0xFF) << 16) | ((a & 0xFF) << 24);
The code right now is repeated for approx. 13'000 cubes. Or i have to say it would be. Because dartium crashes ('Aw, Snap! Something went wrong while displaying this webpage.'). For the sake of 'wtf' if i set a breakpoint on a = 255;
and before continuing remove that breakpoint it works and shows correctly. I have to say that right now to exactly locate the problem i dont use color at all, its just passed as a parameter to another function which makes no use of it. If i dont pass it to the function there is no crash, i guess because it gets optimized out completely.
Well, to make things even weirder the following line works:
int color = (r & 0xFF) | ((g & 0xFF) << 8) | ((b & 0xFF) << 16) | 0xFF000000;
This should technically be the same. Even further testing yielded the following results: If a < 64
in the first version -> no crash. If a >= 64
-> crash.
And to complete the confusion: int a = rnd.nextInt(255);
which gives values >= 64 works everytime with the first version.
/EDIT: And another version that does not crash:
int r = rnd.nextInt(255);
int g = rnd.nextInt(255);
int b = rnd.nextInt(255);
int a = 0xFF.toInt();
int color = (r & 0xFF) | ((g & 0xFF) << 8) | ((b & 0xFF) << 16) | ((a & 0xFF) << 24);
/EDIT2: I have opened an issue on the project, to keep in sync, here is the link: https://code.google.com/p/dart/issues/detail?id=16633
Am I just not seeing something or is this rather unwanted behavior?
Solução
This looks like a VM bug.
Please verify with the latest version if the problem still persists, and file a bug otherwise (http://dartbug.com/new).
thanks!