New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows 1709 (16299) template app is crashing when clicking a link #6982
Comments
@tbottke try this: in // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#include "FrameAnimationDriver.h"
#include "Utils/Helpers.h"
namespace react::uwp {
FrameAnimationDriver::FrameAnimationDriver(
int64_t id,
int64_t animatedValueTag,
const Callback &endCallback,
const folly::dynamic &config,
const std::shared_ptr<NativeAnimatedNodeManager> &manager)
: AnimationDriver(id, animatedValueTag, endCallback, config, manager) {
for (const auto &frame : config.find("frames").dereference().second) {
m_frames.push_back(frame.asDouble());
}
m_toValue = config.find("toValue").dereference().second.asDouble();
}
std::tuple<comp::CompositionAnimation, comp::CompositionScopedBatch> FrameAnimationDriver::MakeAnimation(
const folly::dynamic & /*config*/) {
const auto [scopedBatch, animation] = []() {
const auto compositor = Microsoft::ReactNative::GetCompositor();
return std::make_tuple(
compositor.CreateScopedBatch(
react::uwp::IsRS5OrHigher() ? comp::CompositionBatchTypes::AllAnimations
: comp::CompositionBatchTypes::Animation),
compositor.CreateScalarKeyFrameAnimation());
}();
// Frames contains 60 values per second of duration of the animation, convert
// the size of frames to duration in ms.
std::chrono::milliseconds duration(static_cast<int>(m_frames.size() * 1000.0 / 60.0));
animation.Duration(duration);
auto normalizedProgress = 0.0f;
auto step = 1.0f / m_frames.size();
auto fromValue = GetAnimatedValue()->RawValue();
for (auto frame : m_frames) {
normalizedProgress = std::min(normalizedProgress += step, 1.0f);
animation.InsertKeyFrame(normalizedProgress, static_cast<float>(frame * (m_toValue - fromValue)));
}
if (m_iterations == -1) {
animation.IterationBehavior(winrt::AnimationIterationBehavior::Forever);
} else {
animation.IterationCount(static_cast<int32_t>(m_iterations));
animation.IterationBehavior(winrt::AnimationIterationBehavior::Count);
}
return std::make_tuple(animation, scopedBatch);
}
double FrameAnimationDriver::ToValue() {
return m_toValue;
}
} // namespace react::uwp |
@asklar with your fix the template app is not crashing anymore but I am not able to click any link. Beside that in my own app I am using a WebView that is the next thing that is crashing: |
Hi @tbottke, for the webview one, it looks like that module is using FrameworkElement.IsLoaded which is only supported on 17763 (1803) and up. The second crash is from using UIElement.ActualSize available on 18362 (1903) and up. Unfortunately it's going to be hard to get everything to work on older OS releases unless you are using the version of the UI framework that is independent of the OS (WinUI 3 - but that only works on 1803 and up). You can check more details on how to use WinUI 3 with RNW here. Note that this support is experimental at this point and there are no community modules that currently support WinUI 3. In particular the webview module will have to be reworked to work with WebView2 (see feature request). |
@tbottke that stack just says something threw an exception (on a different thread, possibly), and it's being shuttled over to the UI thread. We'd have to have some more info on what was going on to figure out what happened. You can enable break on WinRT Originate exception in the Exceptions window in the Debug menu. More info here. |
I've sent a PR for the webview issue too: react-native-webview/react-native-webview#1858 |
@asklar there is a bug with older versions of Windows in FlyoutViewManager.cpp at line 179:
https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.input.focusmanager.tryfocusasync?view=winrt-19041
|
nice find. Feel free to submit a PR :) |
Environment
Run the following in your terminal and copy the results here.
npx react-native --version
:4.13.1
npx react-native info
:Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
npx react-native init <projectName> --template react-native@^0.63.2
cd projectName
npx react-native-windows-init --overwrite
Expected Results
App should not crash when clicking a link on Windows 10 1709. Also there might be more problems with this windows version I guess it needs some testing https://microsoft.github.io/react-native-windows/docs/win10-compat says that 1709 is supported.
screenshot:
The text was updated successfully, but these errors were encountered: