mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Fix crash in slider with custom image
Summary:
Changelog: [Internal]
# Why was it crashing?
Crash was caused by `data.getTrackImageRequest()` returning NULL. The crash happened inside `getCoordinator` method. If you look at the implementation of the method below
```
if (request) {
return &request->getObserverCoordinator();
} else {
return nullptr;
}
```
you might notice that we check for NULL, why is it crashing then? And why is it only crashing in production?
The reason is compiler's optimiser, which looks at `data.getTrackImageRequest()`, this method returns `ImageRequest const &` and sees that this method will always return a value, never NULL. Compiler then looks at our `getCoordinator` function, sees that we check there for nullity but since it can never be null, removes that branch.
# Solution
Create new SliderState with non null image observer.
Reviewed By: shergin
Differential Revision: D20491367
fbshipit-source-id: 17b7cf31feabbe6f8ece324a3d329902b2ef6a2d
This commit is contained in:
1 parent
79490d91ad
commit
678f1c4490
1 file changed
+15
@@ -38,6 +38,21 @@ class SliderShadowNode final : public ConcreteViewShadowNode<
|
||||
void setSliderMeasurementsManager(
|
||||
const std::shared_ptr<SliderMeasurementsManager> &measurementsManager);
|
||||
|
||||
static SliderState initialStateData(
|
||||
ShadowNodeFragment const &fragment,
|
||||
SurfaceId const surfaceId,
|
||||
ComponentDescriptor const &componentDescriptor) {
|
||||
auto imageSource = ImageSource{ImageSource::Type::Invalid};
|
||||
return {imageSource,
|
||||
{imageSource, nullptr},
|
||||
imageSource,
|
||||
{imageSource, nullptr},
|
||||
imageSource,
|
||||
{imageSource, nullptr},
|
||||
imageSource,
|
||||
{imageSource, nullptr}};
|
||||
}
|
||||
|
||||
#pragma mark - LayoutableShadowNode
|
||||
|
||||
Size measure(LayoutConstraints layoutConstraints) const override;
|
||||
|
||||
Reference in new issue
Block a user