New issue
Advanced search Search tips

Issue 721258 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: iOS
Pri: 3
Type: Bug



Sign in to add a comment

Check that [UIImage imageWithContentsOfFile:] and [NSData dataWithContentsOfFile:] do not return nil.

Project Member Reported by jif@chromium.org, May 11 2017

Issue description

In debug mode, we should make sure that the following methods (and possibly more) never return nil:
[UIIMage imageWithContentsOfFile:]
[NSData dataWithContentsOfFile:]

It should be done by generalizing the function swizzleUIImageImageNamed() in ios/chrome/app/startup/setup_debugging.mm.

 

Comment 1 by jif@chromium.org, May 11 2017

https://chromereviews.googleplex.com/437977013/ may contain helpful helpers.
Those methods are also used to load file that may not exists (saved session for example) as it is cheaper to try and load data, and handle its absence than checking for existence before loading it.

Comment 3 by jif@chromium.org, May 31 2017

Assuming you are talking about [NSData dataWithContentsOfFile:], here are possible solutions:

1/ Whitelist the files that may not exists.
2/ Only DCHECK when the extension of the file is png/jpg/...
3/ create a category methods [NSData cr_dataWithContentsOfFileThatMayNotExist] that we use when the file may not exist.

Comment 4 by jif@chromium.org, May 31 2017

Erratum: 1/ and 2/ wouldn't work in the case of the saved session:
There's an infinite number of file paths, and the file paths end with .jpg
Summary: Check that [UIImage imageWithContentsOfFile:] and [NSData dataWithContentsOfFile:] do not return nil. (was: Check that [UIIMage imageWithContentsOfFile:] and [NSData dataWithContentsOfFile:] do not return nil.)
Components: -Test>iOS Internals
Owner: ----
Status: Untriaged (was: Assigned)
jif@ is no longer on the team. Releasing his bugs for triage.

Comment 8 by sczs@chromium.org, Jun 27 2018

Labels: Hotlist-GoodFirstBug
Status: Available (was: Untriaged)
Maybe a good first bug? 

Sign in to add a comment