Skip to content

Commit e69f61b

Browse files
coadometa-codesync[bot]
authored andcommitted
Keep ImageManager primitives free of private debug headers (#58792)
Summary: Pull Request resolved: #58792 The public `react/renderer/imagemanager/primitives.h` header included the private `react/renderer/debug/debugStringConvertibleUtils.h` for the inline body of `ImageSource::getDebugProps()`. Because the include was unconditional, any strict consumer of `<React/ImageManager.h>` or `<React/Image.h>` (which reaches `primitives.h` through the Image event emitter) hit the private header guard and failed to compile. Include the public `DebugStringConvertible.h` and `flags.h` headers instead, which provide `SharedDebugStringConvertibleList` and `RN_DEBUG_STRING_CONVERTIBLE`, and keep only the `getDebugProps()` declaration in the header under the existing `RN_DEBUG_STRING_CONVERTIBLE` guard. Move its unchanged implementation into a new `primitives.cpp`, the only place that needs the private debug helpers. Buck, CMake, and CocoaPods already compile every `imagemanager/*.cpp`, so no build-file changes are needed. Changelog: [Internal] ___ Reviewed By: cortinico Differential Revision: D122534446 fbshipit-source-id: 61759cd5041c4ac7571ae2d5e3ab9bc8c28b1ef5
1 parent 9ea7df2 commit e69f61b

2 files changed

Lines changed: 52 additions & 22 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#include <react/renderer/imagemanager/primitives.h>
9+
10+
#if RN_DEBUG_STRING_CONVERTIBLE
11+
#include <react/renderer/debug/debugStringConvertibleUtils.h>
12+
#endif
13+
14+
namespace facebook::react {
15+
16+
#if RN_DEBUG_STRING_CONVERTIBLE
17+
SharedDebugStringConvertibleList ImageSource::getDebugProps(
18+
const std::string& prefix) const {
19+
ImageSource imageSource{};
20+
21+
SharedDebugStringConvertibleList headersList;
22+
for (const auto& header : headers) {
23+
headersList.push_back(debugStringConvertibleItem(
24+
prefix + "-header-" + header.first, header.second));
25+
}
26+
27+
return headersList +
28+
SharedDebugStringConvertibleList{
29+
debugStringConvertibleItem(
30+
prefix + "-type", toString(type), toString(imageSource.type)),
31+
debugStringConvertibleItem(prefix + "-uri", uri, imageSource.uri),
32+
debugStringConvertibleItem(
33+
prefix + "-bundle", bundle, imageSource.bundle),
34+
debugStringConvertibleItem(
35+
prefix + "-scale", scale, imageSource.scale),
36+
debugStringConvertibleItem(
37+
prefix + "-size",
38+
react::toString(size),
39+
react::toString(imageSource.size)),
40+
debugStringConvertibleItem(prefix + "-body", body, imageSource.body),
41+
debugStringConvertibleItem(
42+
prefix + "-method", method, imageSource.method),
43+
debugStringConvertibleItem(
44+
prefix + "-cache", toString(cache), toString(imageSource.cache)),
45+
};
46+
}
47+
#endif
48+
49+
} // namespace facebook::react

‎packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h‎

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
#include <React/Graphics.h>
1717
#include <React/RendererCore.h>
1818
#include <React/RendererDebug.h>
19-
#include <react/renderer/debug/debugStringConvertibleUtils.h>
19+
#include <react/renderer/debug/DebugStringConvertible.h>
20+
#include <react/renderer/debug/flags.h>
2021

2122
namespace facebook::react {
2223

@@ -96,27 +97,7 @@ class ImageSource {
9697
#endif
9798

9899
#if RN_DEBUG_STRING_CONVERTIBLE
99-
SharedDebugStringConvertibleList getDebugProps(const std::string &prefix) const
100-
{
101-
ImageSource imageSource{};
102-
103-
SharedDebugStringConvertibleList headersList;
104-
for (const auto &header : headers) {
105-
headersList.push_back(debugStringConvertibleItem(prefix + "-header-" + header.first, header.second));
106-
}
107-
108-
return headersList +
109-
SharedDebugStringConvertibleList{
110-
debugStringConvertibleItem(prefix + "-type", toString(type), toString(imageSource.type)),
111-
debugStringConvertibleItem(prefix + "-uri", uri, imageSource.uri),
112-
debugStringConvertibleItem(prefix + "-bundle", bundle, imageSource.bundle),
113-
debugStringConvertibleItem(prefix + "-scale", scale, imageSource.scale),
114-
debugStringConvertibleItem(prefix + "-size", react::toString(size), react::toString(imageSource.size)),
115-
debugStringConvertibleItem(prefix + "-body", body, imageSource.body),
116-
debugStringConvertibleItem(prefix + "-method", method, imageSource.method),
117-
debugStringConvertibleItem(prefix + "-cache", toString(cache), toString(imageSource.cache)),
118-
};
119-
}
100+
SharedDebugStringConvertibleList getDebugProps(const std::string &prefix) const;
120101

121102
std::string toString(const Type &typeValue) const
122103
{

0 commit comments

Comments
 (0)