Sdwebimage: error: can't allocate region

Created on 1 May 2018  路  3Comments  路  Source: SDWebImage/SDWebImage

New Issue Checklist

Issue Info

When downloading a large image I receive a crash at the following line:
https://github.com/rs/SDWebImage/blob/e549e1abebeac704b69ae920889dfe465015637b/SDWebImage/SDWebImageImageIOCoder.m#L162

malloc: *** mach_vm_map(size=48775168) failed (error code=3)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

The error does not occur in version 4.3.0. It started happening in version 4.3.1 and still occurs in 4.3.3

Info | Value |
-------------------------|-------------------------------------|
Platform Name | e.g. ios
Platform Version | e.g. 11.0
SDWebImage Version | e.g. 4.3.1, 4.3.2, 4.3.3
Integration Method | e.g. cocoapods
Xcode Version | e.g. Xcode 9
Repro rate | e.g. all the time (100%)
Demo project | Run the demo project at this fork https://github.com/onato/SDWebImage.

Issue Description and Steps

screen shot 2018-05-01 at 12 28 29 pm
screen shot 2018-05-01 at 12 28 54 pm

This is the image I am downloading:
largeimage

bug

All 3 comments

I guess this seems bug from Image/IO.

It seems you're using progressive image load feature. And if I set a breakpoint at that line. I see these output:

2018-05-03 23:28:17.922559+0800 SDWebImage iOS Demo[73708:4848777] imageBlockSetCreate:759: * buffer height mismatch: rect:{0,0,4032,1008} size:{4032,3024}

However, all the information from Image/IO showing the image height is 3024 and filled with transparent color. The current offset Y is 1008.

This Workaround for iOS anamorphic image is kept for historical reason. From 5.x this code already been deleted. See #2303.

I can check it again to test if iOS 7 still need it. (Well, Xcode 9 does not support iOS 7 :)) If need, I will add a if (< iOS 8) { // workaround} condition check. If iOS 7 does not need it, I will delete this code as well as 5.x.

Confirmed...I test with a iOS 7 Real Device iPhone with litte trick in Xcode 9.. 馃槄

iOS 7 Image/IO does not have this bug, so this worksaround code can be removed in iOS 7 as well. The demo's progressive decoding for JPEG/PNG images looks well. (No scratch)

See the result:

2018-05-04 3 55 32

I decide to pick that merge request to 4.x branch as well. So this crash will not happen.

@onato Merged...Wait for 4.3.4 release and no longer Image/IO progressive loading need this workaround.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cyanzhong picture cyanzhong  路  5Comments

Ricardo1980 picture Ricardo1980  路  6Comments

MagLiC picture MagLiC  路  3Comments

paul-lavoine picture paul-lavoine  路  4Comments

ericeddy picture ericeddy  路  6Comments