Closed Bug 1320196 Opened 3 years ago Closed 3 years ago

Eliminate unnecessary string concatenations in ImageCacheKey::ComputeHash

Categories

(Core :: ImageLib, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla53
Tracking Status
firefox51 --- fixed
firefox52 --- fixed
firefox53 --- fixed

People

(Reporter: aosmond, Assigned: aosmond)

References

Details

(Whiteboard: gfx-noted)

Crash Data

Attachments

(1 file, 1 obsolete file)

Hashing several strings appended together, and hashing them individually should result in the same value, except the latter is a much cheaper option.

http://searchfox.org/mozilla-central/rev/b4e6fa3527436bdbcd9dd2e1982382fe423431f3/image/ImageCacheKey.cpp#158

This allow triggers a malloc, which shows up in crash signatures, such as:

https://crash-stats.mozilla.com/report/index/77317c14-819d-4853-99ac-7bcaf2161118

The malloc is so big (presumably) because the URI spec can be quite large if it is just a base64 encoded image instead of a normal URL.
Assignee: nobody → aosmond
Status: NEW → ASSIGNED
Priority: -- → P3
Whiteboard: gfx-noted
Crash Signature: [@ OOM | large | NS_ABORT_OOM | nsACString_internal::Assign | mozilla::image::ImageCacheKey::ImageCacheKey ]
Comment on attachment 8814245 [details] [diff] [review]
Remove string concat in ImageCacheKey::ComputeHash, v1

Nice!

ImageURL::ComputeHash isn't a generic function, but rather specific to ImageCacheKey. So maybe make it private and mark ImageCacheKey as a friend class?
Attachment #8814245 - Flags: review?(tnikkel) → review+
Incorporate review feedback.
Attachment #8814245 - Attachment is obsolete: true
Attachment #8814389 - Flags: review+
Pushed by aosmond@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/b8cdb59ac18b
Avoid string concatenation when computing the hash for ImageCacheKey. r=tnikkel
https://hg.mozilla.org/mozilla-central/rev/b8cdb59ac18b
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Comment on attachment 8814389 [details] [diff] [review]
Remove string concat in ImageCacheKey::ComputeHash, v2 [carries r=tnikkel]

Approval Request Comment
[Feature/regressing bug #]: N/A
[User impact if declined]: May crash in low memory conditions.
[Describe test coverage new/current, TreeHerder]: The crash itself has only been observed in crash reports, not easily reproducible. However the crash occurs on a success path used every time an image is loaded and is thus well exercised by existing mochi/web-platorm/reftests.
[Risks and why]: Minimal, there was no functional change, only the need for some temporary allocations on the heap was removed.
[String/UUID change made/needed]: N/A
Attachment #8814389 - Flags: approval-mozilla-aurora?
Comment on attachment 8814389 [details] [diff] [review]
Remove string concat in ImageCacheKey::ComputeHash, v2 [carries r=tnikkel]

Approval Request Comment
[Feature/regressing bug #]: N/A
[User impact if declined]: May crash in low memory conditions.
[Describe test coverage new/current, TreeHerder]: The crash itself has only been observed in crash reports, not easily reproducible. However the crash occurs on a success path used every time an image is loaded and is thus well exercised by existing mochi/web-platorm/reftests.
[Risks and why]: Minimal, there was no functional change, only the need for some temporary allocations on the heap was removed.
[String/UUID change made/needed]: N/A
Attachment #8814389 - Flags: approval-mozilla-beta?
Comment on attachment 8814389 [details] [diff] [review]
Remove string concat in ImageCacheKey::ComputeHash, v2 [carries r=tnikkel]

reduce risk of OOM, take in aurora52
Attachment #8814389 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Comment on attachment 8814389 [details] [diff] [review]
Remove string concat in ImageCacheKey::ComputeHash, v2 [carries r=tnikkel]

Fix a crash. Beta51+. Should be in 51 beta 5.
Attachment #8814389 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.