Closed shaozg closed 7 years ago
+1
+1 for me too. @piv199 you just barely beat me to it 😏
+1 for me too, same problem running Xcode7.3.1
Thanks for the feedback. Do any of you have a reliable way to reproduce this, or is it purely random ?
@guillaume-algis I cannot speak for everyone above, but for me all I do is:
It happens every single time I open Package Manager.
The same as @bshewmak , also about b's/c's
Ugh. Can't reproduce on my machine with Xcode 7.3.1.
Ok weird question: what type of mouse are you guys using?
It looks like https://github.com/alcatraz/Alcatraz/pull/246/commits/538f20ac39c423c125bc239dbad31e3fa9e9b543 would have fixed a bug related to images, but it never got merged. If you have the time, I would be cool if you could try and apply the patch on top of master
, build Alcatraz on your machine and test again :)
Interesting question....
@guillaume-algis I'm using an Apple Magic Mouse.
@guillaume-algis default trackpad
UPD: Ok, just ran the latest commit from that repository and... it works without crash however no images are displayed into cells.
Researching...
@guillaume-algis
Okay I've downloaded master branch from this repository, and added logger for every cell when it comes to setting image and I found that:
2016-08-08 23:58:11.778 Xcode[41322:1094185] image operation for BodyBuilder
And then it crashes... Then I added before setting image inside cell:
if ([package.name isEqualToString:@"BodyBuilder"]) {
return view;
}
And it finally works! It's not crashing anymore!!!
@guillaume-algis
This plugin has bad image
https://raw.githubusercontent.com/materik/bodybuilder/master/screenshot.gif
When cache haven't found an image for this plugin it starts downloading it again, once it finished it sets the image and calls reload cell at index path and recalculate height
po image.size
(width = 0, height = 0)
Well, crashes this method:
[self fetchAndCacheImageForPackage:package progress:NULL completion:^(NSImage *image) {
//code
}];
if add inside ATZDownloader:downloadFileFromPath:progress:completion, it works (however preview for 'BodyBuilder' is still displaying as empty, but displaying.
if (!image || (image.size.width == 0 && image.size.height == 0))
return;
Thanks for all the work @piv199 !
I'm not sure what you mean by "bad image". The file seems to be a valid GIF on my machine:
$ wget 'https://raw.githubusercontent.com/materik/bodybuilder/master/screenshot.gif'
--2016-08-08 23:49:52-- https://raw.githubusercontent.com/materik/bodybuilder/master/screenshot.gif
Resolving raw.githubusercontent.com... 151.101.60.133
Connecting to raw.githubusercontent.com|151.101.60.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2075190 (2.0M) [image/gif]
Saving to: ‘screenshot.gif’
screenshot.gif 100%[===============================================================================>] 1.98M --.-KB/s in 0.1s
2016-08-08 23:49:53 (15.0 MB/s) - ‘screenshot.gif’ saved [2075190/2075190]
$ file screenshot.gif
screenshot.gif: GIF image data, version 89a, 660 x 786
When your patch
if ([package.name isEqualToString:@"BodyBuilder"]) {
return view;
}
is in place, do you manage to scroll the full list (ie. download every other image)? Finding other images which make Alcatraz crash could help pinpoint what exactly is happening here.
Also, that's be cool if you could add NSLog(@"%@", image);
just after
NSImage *image = [[NSImage alloc] initWithData:responseData];
if (!image)
return;
without any other modification, just to see what's inside the NSImage before the crash. Thanks!
@guillaume-algis
Got the same as you.
MBP-Olexiy:~ alex$ wget 'https://raw.githubusercontent.com/materik/bodybuilder/master/screenshot.gif'
--2016-08-09 00:58:18-- https://raw.githubusercontent.com/materik/bodybuilder/master/screenshot.gif
Resolving raw.githubusercontent.com... 151.101.12.133
Connecting to raw.githubusercontent.com|151.101.12.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2075190 (2.0M) [image/gif]
Saving to: ‘screenshot.gif’
screenshot.gif 100%[===================>] 1.98M 3.14MB/s in 0.6s
2016-08-09 00:58:20 (3.14 MB/s) - ‘screenshot.gif’ saved [2075190/2075190]
MBP-Olexiy:~ alex$ file screenshot.gif
screenshot.gif: GIF image data, version 89a, 660 x 786
After patching I managed to scroll slowly all list! Nothing has crashed!
As for image. My browser 'Safari' doesn't display image:
But Chrome does! This is animation gif, it's not an image. Maybe there could be a problem?
My intuition is that we're not handling network errors well. So you probably had an error when Alcatraz downloaded the gif (which is quite large), and we cached it anyway.
I reproduced consistently by damaging the data returned by the network:
NSMutableData *foo = [responseData mutableCopy];
const char b[100000] = {0};
[foo replaceBytesInRange:NSMakeRange(1000, 1000000) withBytes:b length:1000000];
NSImage *image = [[NSImage alloc] initWithData:foo];
The NSImage is then malformed, but not nil
, which is the only thing we are checking:
Aug 9 00:09:40 Xcode[35704] <Error>: ImageIO: _CGImagePluginInitGIF 4634 - malformed GIF frame#0 (660 x 786) - [canvasSize: 518760 frameDataSize: 255 adjustment: 1]
Aug 9 00:09:40 Xcode[35704] <Error>: ImageIO: _CGImagePluginInitGIF 4634 - malformed GIF frame#0 (660 x 786) - [canvasSize: 518760 frameDataSize: 255 adjustment: 1]
2016-08-09 00:09:40.439 Xcode[35704:6634688] <NSImage 0x600004875e80 Size={0, 0} Reps=(
)>
I'm gonna try to reproduce by simulating a network error with a local webserver serving the image. If that's conclusive, I'll fix the error handling in ATZDownloader (which we should fix anyway).
In the meantime, I think you can close https://github.com/materik/bodybuilder/issues/8, as it's probably not the source of the problem, and their image is definitely valid (it displays fine for me in Safari, Chrome, Preview, and file
and identify
report no problems) :)
Edit: Regarding the gif, I think we need to have a discussion on what we allow on alcatraz-packages. In my opinion, a 2.7MB image is way too much. But that's another topic.
@guillaume-algis
Just set breakpoint for creating image from response and got (bytes are normal):
(lldb) po responseData.length
2075190
However [[NSImage alloc] initWithData:responseData]
returns
(lldb) po [[NSImage alloc] initWithData:responseData]
<NSImage 0x618000668100 Size={0, 0} Reps=(
)>
@piv199 wait... you're telling me that even after quitting all instances of Xcode, each time you re-download the image it crashes?
If so, I'm dumbfound. I'm getting the exact same responseData length, and my NSImage is created successfully.
Would you mind writing the responseData you're receiving to disk and sending it my way?
Adding
if ([package.name isEqualToString:@"BodyBuilder"]) {
[responseData writeToFile:@"/tmp/BodyBuilderScreenshot.gif" atomically:YES];
}
just before NSImage *image = [[NSImage alloc] initWithData:responseData];
should do the trick, then you can email it to me (zipped if possible) at guillaume.algis@gmail.com.
Thanks!
@guillaume-algis oh I have a bit lag, so I sent you from 2 to 4 messages with the same file :) I'm sorry.
Preview cannot open the file on my Mac. It says the file is damaged or in incorrect format. But chrome opens it successfully. Safari fails...
@guillaume-algis
Look, I don't know why, but it's not shown even in Safari in github repo. I'm using 10.11.6 (15G31).
oh I have a bit lag, so I sent you from 2 to 4 messages with the same file :) I'm sorry.
Don't worry about it :)
The file you sent me is the exact same (same md5 hash) than the one I'm downloading.
I don't get it. It displays fine for me (Safari 9.1.1 on El Cap 10.11.5).
Could you take a look at the logs in Safari's developer tools, and in Console.app see if there's by any chance any error poping up?
In any case, I'll open a PR in just a minute fixing the crash. But I'll be glad if we could continue trying to find the root cause of the problem; finding why Safari isn't rendering the image is a good lead.
(But maybe not tonight, it's getting a bit late here ;) )
@guillaume-algis I'm confused, I can't understand why it's not showing... Safari: Version 9.1.2 (11601.7.7)
When I open gif image safari shows NO error in console.
Then I go to debug and set all breakpoints enabled. The only one breakpoint is occurred on this page is:
Fixed in #480 / Alcatraz 1.1.19