Files
react-native/ReactCommon/react/renderer/mounting/TelemetryController.cpp
T
Samuel Susla 3a5eedffff Remove noexcept from TelemetryController
Summary:
Changelog: [internal]

There are two exceptions inside `TelemetryController::pullTransaction`:
- Empty Optional cannot be unwrapped
- mutex lock failed: Invalid argument

By marking this method `noexcept`, stack trace is lost and it makes it more difficult to track down the issue.

What does compiler do if a method is marked `noexcept`?

```
void f() noexcept {
    try {
        // do work
    }
    catch (...) {
        std::terminate(); // This is the std::terminate() we are seeing in stack traces.
    }
}
```

Removing noexcept specifier might give us more information about the exception.

Reviewed By: JoshuaGross

Differential Revision: D24477861

fbshipit-source-id: 80f26e9ab160a5330c2848b89a01d60bfc0a4611
2020-10-23 02:34:04 -07:00

58 lines
1.6 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "TelemetryController.h"
#include <react/renderer/mounting/MountingCoordinator.h>
namespace facebook {
namespace react {
TelemetryController::TelemetryController(
MountingCoordinator const &mountingCoordinator) noexcept
: mountingCoordinator_(mountingCoordinator) {}
bool TelemetryController::pullTransaction(
std::function<void(MountingTransactionMetadata metadata)> willMount,
std::function<void(ShadowViewMutationList const &mutations)> doMount,
std::function<void(MountingTransactionMetadata metadata)> didMount) const {
auto optional = mountingCoordinator_.pullTransaction();
if (!optional.has_value()) {
return false;
}
auto transaction = std::move(*optional);
auto surfaceId = transaction.getSurfaceId();
auto number = transaction.getNumber();
auto telemetry = transaction.getTelemetry();
auto numberOfMutations = transaction.getMutations().size();
mutex_.lock();
auto compoundTelemetry = compoundTelemetry_;
mutex_.unlock();
willMount({surfaceId, number, telemetry, compoundTelemetry});
telemetry.willMount();
doMount(std::move(transaction.getMutations()));
telemetry.didMount();
compoundTelemetry.incorporate(telemetry, numberOfMutations);
didMount({surfaceId, number, telemetry, compoundTelemetry});
mutex_.lock();
compoundTelemetry_ = compoundTelemetry;
mutex_.unlock();
return true;
}
} // namespace react
} // namespace facebook