Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
210 commits
Select commit Hold shift + click to select a range
51368d0
Added C# ReactContext for Module Initialize method (#4722)
vmoroz Apr 27, 2020
fc72e04
Update rex-win32 version to something more recent (#4725)
acoates-ms Apr 27, 2020
793ec25
Remove rnpm-plugin-windows pacakge (#4724)
acoates-ms Apr 27, 2020
edc1b87
Fixes husky missing error (#4727)
jonthysell Apr 27, 2020
5034ff3
Bump semver from 7.1.3 to 7.3.2 (#4730)
dependabot-preview[bot] Apr 27, 2020
ac3e39f
Bump fp-ts from 2.5.3 to 2.5.4 (#4729)
dependabot-preview[bot] Apr 27, 2020
a8ab5f4
Bump envinfo from 7.5.0 to 7.5.1 (#4728)
dependabot-preview[bot] Apr 27, 2020
c440b35
Delete vnext\README.md and create a build task to copy the root one t…
acoates-ms Apr 27, 2020
2453f8e
applying package updates ***NO_CI***
rnbot Apr 28, 2020
567fc48
Start migrating WUX 👉 MUX (#4715)
asklar Apr 28, 2020
ccbd12b
Update react version (#4734)
kaiguo Apr 28, 2020
64144a9
Exclude test projects and proposals from being published in the npm p…
dannyvv Apr 28, 2020
f7be64d
Update version number of the Azure DevOps PR validation step (#4738)
dannyvv Apr 28, 2020
808ca32
applying package updates ***NO_CI***
rnbot Apr 29, 2020
ee00cce
Auto-detect RTL locale and apply to root view (#4732)
kmelmon Apr 29, 2020
5edb66b
Expose Debug macro for hresult_error. Start catching these... (#4742)
asklar Apr 29, 2020
36ca14d
Update tscodegen to version based on 0.62 (#4747)
acoates-ms Apr 29, 2020
d33450d
Bump @types/react-native from 0.62.4 to 0.62.5 (#4748)
dependabot-preview[bot] Apr 29, 2020
297e217
Remove unnecessary CLI elevation (#4745)
asklar Apr 29, 2020
f923f98
Refactor TestHook out of ViewManagerBase and special case layout prop…
asklar Apr 29, 2020
800850c
applying package updates ***NO_CI***
rnbot Apr 30, 2020
1ec1663
.net projects need more work to build a package layout (#4751)
asklar Apr 30, 2020
15ad43e
Expose YellowBox functionality to native code (#4740)
asklar Apr 30, 2020
1ca0c29
Package Version Fixes (#4752)
NickGerleman Apr 30, 2020
0f2fca4
Stop publishing ReactUwp NuGet Package (#4753)
NickGerleman Apr 30, 2020
3e1e61d
applying package updates ***NO_CI***
rnbot Apr 30, 2020
2a86937
Bump @babel/runtime from 7.9.2 to 7.9.6 (#4758)
dependabot-preview[bot] Apr 30, 2020
95a1987
Bump @babel/preset-env from 7.9.5 to 7.9.6 (#4756)
dependabot-preview[bot] Apr 30, 2020
9d9a541
Removed the ref count work around from classes derived from ReactAppl…
vmoroz Apr 30, 2020
fb48078
Bump @babel/core from 7.9.0 to 7.9.6 (#4757)
dependabot-preview[bot] Apr 30, 2020
d2583c9
Add a step in CI to upload verdaccio logs to diagnose package restore…
dannyvv Apr 30, 2020
518284b
Minor cleanup: Remove unused namespace from C# files (#4763)
dannyvv Apr 30, 2020
06370db
applying package updates ***NO_CI***
rnbot May 1, 2020
8c69344
Update mouseEnter/mouseLeave algorithm (#4574)
aschultz May 1, 2020
800e416
Delay load ChakraCore.dll (#4773)
tudorms May 1, 2020
3bcd8a1
applying package updates ***NO_CI***
rnbot May 2, 2020
56e0853
Build logic to create test bundles, test to call JS function (#4765)
aeulitz May 2, 2020
cc400a0
Bump beachball from 1.30.2 to 1.31.0 (#4769)
dependabot-preview[bot] May 2, 2020
a6d5ff4
Implement WinRTWebSocket unit tests (#4767)
JunielKatarn May 2, 2020
fe26584
applying package updates ***NO_CI***
rnbot May 3, 2020
ccf291b
Add parallel MsBuild support (/m) when building the generated solutio…
dannyvv May 4, 2020
409537e
Bump io-ts from 2.2.1 to 2.2.2 (#4784)
dependabot-preview[bot] May 4, 2020
023ca8e
Bump @types/react-native from 0.62.5 to 0.62.7 (#4783)
dependabot-preview[bot] May 4, 2020
7379a56
Bump @microsoft/api-documenter from 7.7.19 to 7.7.20 (#4782)
dependabot-preview[bot] May 4, 2020
6bfc38a
Kill verdacio server before uploading logs and name artifacts by job …
dannyvv May 4, 2020
96c1c93
Fix appPackage path in deploy.js (#4762)
kaiguo May 4, 2020
5232091
applying package updates ***NO_CI***
rnbot May 5, 2020
f467d8b
RNW on WinUI3! (#4766)
asklar May 5, 2020
a20e950
Treat yes the same as y in template overwrite prompt (#4788)
acoates-ms May 5, 2020
9bce53e
Support --version file:<path> for running init against local changes …
acoates-ms May 5, 2020
9c82567
applying package updates ***NO_CI***
rnbot May 6, 2020
67781f6
Don't delete nuget.exe if using locally-installed (e.g. chocolatey) (…
asklar May 6, 2020
6398c2d
Fix @office-iss/react-native-win32 sourcemap (#4797)
statm May 6, 2020
76b3478
[Trivial] Fix typo in msbuildtools.js (#4803)
statm May 6, 2020
80cef10
Disable CxxFrameHandler4 (#4805)
NickGerleman May 6, 2020
c18e0c1
Switch package layout to use `files` in `package.json` rather than `.…
dannyvv May 6, 2020
8940e5e
Don't bundle during intellisense (#4800)
asklar May 6, 2020
2cb78b5
Bump @microsoft/api-documenter from 7.7.20 to 7.8.0 (#4808)
dependabot-preview[bot] May 6, 2020
608b98b
Fix publish pipeline (#4815)
aeulitz May 6, 2020
02d40fb
Bump @microsoft/api-extractor from 7.7.13 to 7.8.0 (#4807)
dependabot-preview[bot] May 6, 2020
b26c409
applying package updates ***NO_CI***
rnbot May 7, 2020
0458337
Ensure WebSocket write lifetime (#4790)
JunielKatarn May 7, 2020
6088cb0
Ensure InitializeCore is run before app code (#4814)
acoates-ms May 7, 2020
1cff896
Bump stacktrace-parser from 0.1.9 to 0.1.10 (#4821)
dependabot-preview[bot] May 7, 2020
605e3f8
Upgrade the shared managed project to a proper csharp library. (#4793)
dannyvv May 7, 2020
206b925
applying package updates ***NO_CI***
rnbot May 8, 2020
082b57f
Set C# langversion of templates back to 7.3 from 8.0 (#4828)
dannyvv May 8, 2020
c51c3ad
Correct WebSocket binary message tagging (#4829)
JunielKatarn May 8, 2020
e3aa341
Update README.md (#4826)
harinikmsft May 8, 2020
951333f
Remove V8 and Hermes by default (#4820)
asklar May 8, 2020
e4a5f45
Align local metro config with future CLI changes (#4827)
acoates-ms May 8, 2020
ccce488
Added Microsoft.ReactNative.IntegrationTests project to Microsoft.Rea…
vmoroz May 8, 2020
4cfd393
Single Targets for CLI app templates (#4816)
jonthysell May 8, 2020
4255e81
Ensure Beachball Uses The Right Branch for Experimental NuGet PR Test…
NickGerleman May 8, 2020
b590fff
Implemented PropertyBag for ReactContext and ReactInstanceSettings (#…
vmoroz May 8, 2020
2db09bc
applying package updates ***NO_CI***
rnbot May 9, 2020
858fdce
Reenable V8 for desktop projects (#4840)
tudorms May 9, 2020
d374932
applying package updates ***NO_CI***
rnbot May 10, 2020
cf658ba
Improve run_wdio to print out failed tests (#4843)
asklar May 11, 2020
c40cc0e
Fire onLoad event when a bitmap image is opened (#4750)
lamxdoan May 11, 2020
55091b9
Expose ability for apps to provide their own RedBox implementation (#…
acoates-ms May 11, 2020
a15b3bf
Bump fp-ts from 2.5.4 to 2.6.0 (#4871)
dependabot-preview[bot] May 11, 2020
e596d14
applying package updates ***NO_CI***
rnbot May 12, 2020
d5e8bdc
Fixed ReactContext copy/move semantic (#4870)
vmoroz May 12, 2020
49e6547
Add ReactNativeHost to Win32 C++/WinRT ABI (#4848)
aeulitz May 12, 2020
8033b54
Use spec file for DevSettings NativeModule (#4873)
acoates-ms May 12, 2020
dbe875f
Handle HTTP errors in DevSupportManager. (#4880)
JunielKatarn May 12, 2020
be55650
applying package updates ***NO_CI***
rnbot May 13, 2020
d1abb36
Allow storing non-WinRT types in ReactPropertyBag (#4884)
vmoroz May 13, 2020
e633704
Use DispatcherQueue instead of CoreDispatcher for Mso::DispatchQueue …
vmoroz May 13, 2020
64aede7
RNW dependencies (#4876)
asklar May 13, 2020
c27b585
support running from web (#4892)
asklar May 13, 2020
5c024c0
Bump typescript from 3.8.3 to 3.9.2 (#4890)
dependabot-preview[bot] May 13, 2020
a8cd170
Bump lerna from 3.20.2 to 3.21.0 (#4889)
dependabot-preview[bot] May 13, 2020
904f7c0
BugFix: fix default tabindex stomping over acceptsKeyboardFocus (#4893)
kmelmon May 13, 2020
5b96a1f
Update e2e testing doc with CI debugging info (#4897)
asklar May 13, 2020
525bbe2
Update rnw-dependencies (#4894)
asklar May 13, 2020
7849279
applying package updates ***NO_CI***
rnbot May 14, 2020
579a25b
ViewWin32 Accessibility: labeledBy, describedBy (#4883)
PPatBoyd May 14, 2020
a8cf72c
Remove unused life cycle event callbacks in ReactNativeHost (#4891)
kaiguo May 14, 2020
f6f43e1
Reduce PCH Sizes (#4886)
NickGerleman May 14, 2020
fdcffd4
Playground app not specifying the UIDispatcher (#4896)
acoates-ms May 14, 2020
069073f
Bump @types/react-native from 0.62.7 to 0.62.8 (#4888)
dependabot-preview[bot] May 14, 2020
204bc9e
Move Microsoft.ReactNative pch files in a Pch subfolder (#4898)
vmoroz May 14, 2020
1d27709
[Security] Bump handlebars from 4.5.3 to 4.7.6 (#4903)
dependabot-preview[bot] May 14, 2020
c393438
improve treedump capabilities (#4844)
asklar May 14, 2020
7de1f38
winui3 option for app project template (and update C++ template) (#4799)
asklar May 14, 2020
178583f
Install exact version of WinAppDriver (#4905)
asklar May 14, 2020
45f814c
applying package updates ***NO_CI***
rnbot May 15, 2020
e0f591e
Some projects have target instead of bin folders (#4910)
asklar May 15, 2020
e15746b
Bump @types/semver from 7.1.0 to 7.2.0 (#4906)
dependabot-preview[bot] May 15, 2020
2d85b6a
JustMyXaml.ps1 (#4914)
asklar May 15, 2020
0ed42ca
Bump @microsoft/api-extractor from 7.8.0 to 7.8.1 (#4916)
dependabot-preview[bot] May 15, 2020
a086d5b
Bump @types/yargs from 15.0.4 to 15.0.5 (#4907)
dependabot-preview[bot] May 15, 2020
146f224
Move playground-win32 to Microsoft.ReactNative (#4895)
acoates-ms May 15, 2020
ac17297
Bump @types/es6-collections from 0.5.31 to 0.5.32 (#4917)
dependabot-preview[bot] May 15, 2020
2dc0f33
applying package updates ***NO_CI***
rnbot May 16, 2020
ce937eb
Prevent hard crash on invalid jsx (button inside text e.g.) (#4921)
asklar May 16, 2020
f5deff4
E2ETest - use TreeDumpLibrary from nuget (#4912)
asklar May 16, 2020
251f520
ReactNonAbiValue for IReactPropertyBag non-ABI values (#4911)
vmoroz May 16, 2020
0692127
Fixed ReactContext CallJSFunction and EmitJSEvent (#4922)
vmoroz May 16, 2020
d517336
applying package updates ***NO_CI***
rnbot May 17, 2020
efa28f0
Ensure Override Prompts Create Integral Issue Numbers (#4931)
NickGerleman May 18, 2020
c9d9d5c
Add support for 0..n args in native module callbacks (#4929)
vmoroz May 18, 2020
c46c5dd
Start removal of ReactUWP (#4920)
acoates-ms May 18, 2020
8fd9bf8
Fixes for bundle loading and back handler crash using xaml islands (#…
acoates-ms May 18, 2020
bf95c14
Fix compile errors with Clang 10.0.0 (#4937)
christophpurrer May 18, 2020
aba50b6
Adapt ViewWin32, etc to "accessibilityState" (#4932)
NickGerleman May 18, 2020
b83575c
Bump @microsoft/api-documenter from 7.8.0 to 7.8.1 (#4943)
dependabot-preview[bot] May 18, 2020
f930faf
Bump @types/lodash from 4.14.150 to 4.14.151 (#4942)
dependabot-preview[bot] May 18, 2020
eee19c1
applying package updates ***NO_CI***
rnbot May 19, 2020
60afde9
Reduce the changes in our custom metro config (#4939)
acoates-ms May 19, 2020
1e55356
Implement Keyboarding/Gamepad Activation for Pressability (#4930)
NickGerleman May 19, 2020
7e3e737
Update the react-native-windows-init template to use the managed libr…
dannyvv May 19, 2020
022aa95
Bump fp-ts from 2.6.0 to 2.6.1 (#4909)
dependabot-preview[bot] May 19, 2020
1a7d27a
Build Win32 ReactNativeHost from shared source (#4924)
aeulitz May 19, 2020
4f6194d
applying package updates ***NO_CI***
rnbot May 20, 2020
baba475
ReactNotificationService to allow communication between native module…
vmoroz May 20, 2020
4050174
Bump @microsoft/api-documenter from 7.8.1 to 7.8.2 (#4952)
dependabot-preview[bot] May 20, 2020
09a610e
Bump @microsoft/api-extractor from 7.8.1 to 7.8.2 (#4951)
dependabot-preview[bot] May 20, 2020
b3fc68f
Deploy from layout (#4945)
asklar May 20, 2020
282ee22
Bump typescript from 3.9.2 to 3.9.3 (#4956)
dependabot-preview[bot] May 20, 2020
95f55d3
applying package updates ***NO_CI***
rnbot May 21, 2020
8253a68
Work around regression in UWP app packaging in VS 16.5-16.6 (#4958)
asklar May 21, 2020
bea629d
Bump @types/lodash from 4.14.151 to 4.14.152 (#4955)
dependabot-preview[bot] May 21, 2020
70baa5f
Fixed Microsoft.ReactNative build in VS 16.6.0 (#4962)
vmoroz May 21, 2020
1fe030a
Fix animation bug (#4964)
kmelmon May 21, 2020
b4b50e9
Bump @microsoft/api-extractor from 7.8.2 to 7.8.3 (#4969)
dependabot-preview[bot] May 21, 2020
9ba3b78
Bump @microsoft/api-documenter from 7.8.2 to 7.8.3 (#4968)
dependabot-preview[bot] May 21, 2020
17624a7
Bump io-ts from 2.2.2 to 2.2.3 (#4966)
dependabot-preview[bot] May 21, 2020
a55f0a5
Bump diff-match-patch from 1.0.4 to 1.0.5 (#4967)
dependabot-preview[bot] May 21, 2020
23cb6da
Update CI pipeline to upload build logs (#4971)
dannyvv May 21, 2020
7df439c
Add preprocess target to M.RN and missing deploy target in playground…
asklar May 21, 2020
1ffc221
Fix spacing and extra dot in copyright of the property sheets (#4970)
dannyvv May 21, 2020
7da2d4e
Standardize version of Microsoft.NETCore.UniversalWindowsPlatform to …
dannyvv May 21, 2020
68b3968
Remove unneeded reference form Microsoft.ReactNative.Managed (#4977)
dannyvv May 21, 2020
b2241a6
Add info about yarn format to contribution docs. (#4981)
rectified95 May 21, 2020
2ce41cf
Only emit click events for left mouse button (#4878)
rectified95 May 21, 2020
225df52
applying package updates ***NO_CI***
rnbot May 22, 2020
ed7ee2d
Drop LazyDevSupportManager (#4984)
JunielKatarn May 22, 2020
cd9206e
App projects only builds from clean (i.e. the first time only) (#4983)
asklar May 22, 2020
0e0dba5
Move several stubs from TS to flow (#4976)
acoates-ms May 22, 2020
c23d3de
Implemented support for native module std::weak_ptr (#4980)
vmoroz May 22, 2020
981e3b5
Bump @microsoft/api-documenter from 7.8.3 to 7.8.5 (#4989)
dependabot-preview[bot] May 22, 2020
f31136e
Bump beachball from 1.31.0 to 1.31.1 (#4988)
dependabot-preview[bot] May 22, 2020
05779f2
Fix ReactInstance error state to avoid crashes (#4986)
vmoroz May 22, 2020
198ce2e
Bump @microsoft/api-extractor from 7.8.3 to 7.8.5 (#4990)
dependabot-preview[bot] May 22, 2020
8dcf516
Move AppState and DeviceInfo to use module spec files (#4991)
acoates-ms May 22, 2020
b814ee3
applying package updates ***NO_CI***
rnbot May 23, 2020
1a96ee7
Remove unneeded or undesirable eslint suppressions (#4994)
NickGerleman May 24, 2020
85b01cb
Rename override-tools to react-native-platform-override (#4993)
NickGerleman May 25, 2020
310527a
applying package updates ***NO_CI***
rnbot May 26, 2020
35137fb
Create Microsoft.ReactNative.ComponentTests.vcxproj (#5006)
ZihanChen-MSFT May 26, 2020
fc6b195
Bump @types/react-native from 0.62.10 to 0.62.11 (#5004)
dependabot-preview[bot] May 26, 2020
bca7a98
Bump lerna from 3.21.0 to 3.22.0 (#5005)
dependabot-preview[bot] May 26, 2020
f2fffbd
Move I18nManager to spec based native module (#4999)
acoates-ms May 26, 2020
96f7e82
Allow developers to independently set hostname and port. (#4979)
nasadigital May 26, 2020
7236d61
Add UIDispatcher property to ReactInstanceSettings and IReactContext …
vmoroz May 26, 2020
bc7c516
applying package updates ***NO_CI***
rnbot May 27, 2020
9a4aa3c
Fix loading SampleAppCpp in VS 16.6.0 (#4982)
vmoroz May 27, 2020
c99549b
Change ABITest project to GTest executable (#4997)
aeulitz May 27, 2020
a85f4c8
ReactApplication should not impose a ReactRootView (#4949)
asklar May 27, 2020
ed809a4
Create JSI implementation for IJSValueReader and IJSValueWriter (#5009)
ZihanChen-MSFT May 27, 2020
f2df8ed
Use reg-free WinRT in Desktop.ABITests project (#5013)
aeulitz May 27, 2020
67df4c3
applying package updates ***NO_CI***
rnbot May 28, 2020
ce5b8b4
Obtain Google Test Adapter path dynamically (#5027)
JunielKatarn May 28, 2020
7a7488d
Remove unused ABI definitions (#5030)
vmoroz May 28, 2020
d0c938f
Attempt to fix intermittent failures in E2E tests (#5040)
acoates-ms May 28, 2020
6eff734
Bump @microsoft/api-documenter from 7.8.5 to 7.8.8 (#5035)
dependabot-preview[bot] May 28, 2020
77bbf45
Build ChakraRuntime in ComponentTests with one test case (#5032)
ZihanChen-MSFT May 28, 2020
9001168
Bump @babel/preset-env from 7.9.6 to 7.10.1 (#5039)
dependabot-preview[bot] May 28, 2020
5a01200
Bump fp-ts from 2.6.1 to 2.6.2 (#5019)
dependabot-preview[bot] May 28, 2020
74da808
Update shared props to have csc emit absolute paths on errors and war…
dannyvv May 28, 2020
77dea41
Add support for long paths to rnw-dependencies.ps1 (#5045)
asklar May 28, 2020
db418d9
applying package updates ***NO_CI***
rnbot May 29, 2020
2809c9a
Adds a XamlUIService property to IReactContext, which exposes Element…
acoates-ms May 29, 2020
ff72d1b
Remove ReactWindowsCore projects (#5012)
JunielKatarn May 29, 2020
22993f9
Fixes CLI C# app not deploying (#5042)
jonthysell May 29, 2020
8bbd689
Add test cases for (Dynamic|Jsi)(Reader|Writer) (#5046)
ZihanChen-MSFT May 29, 2020
e9cebd1
applying package updates ***NO_CI***
rnbot May 30, 2020
e2d328a
Block all ProjectImports.zip files (#5050)
asklar May 30, 2020
268025f
Add CI loop for markdown docs (#5056)
asklar May 30, 2020
7c1b590
applying package updates ***NO_CI***
rnbot May 31, 2020
79a931c
Update projects to use shared props/targets (#4987)
dannyvv May 31, 2020
00ab671
applying package updates ***NO_CI***
rnbot Jun 1, 2020
0df2043
More attempts at making E2E test more reliable (#5055)
acoates-ms Jun 1, 2020
20cc280
Allow Override Tooling to Use Nightly Builds (#5024)
NickGerleman Jun 1, 2020
80d1a40
Enable ReactNativeHost integration test (#5071)
vmoroz Jun 1, 2020
d029386
Cherry pick PR #5071 for JSCallFunction queuing
vmoroz Jun 12, 2020
ef034f2
Change files
vmoroz Jun 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "prerelease",
"comment": "Cherry pick PR #5071 for JSCallFunction queuing",
"packageName": "react-native-windows",
"email": "vmorozov@microsoft.com",
"dependentChangeType": "patch",
"date": "2020-06-12T05:39:50.177Z"
}
1 change: 1 addition & 0 deletions vnext/Microsoft.ReactNative/ReactHost/React.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ enum class ReactInstanceState {
WaitingForDebugger,
Loaded,
HasError,
Unloaded,
};

/**An Office wrapper that extends FB's React Instance and makes it a 1:1 relationship with the bundle,
Expand Down
69 changes: 54 additions & 15 deletions vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,13 @@ winrt::Microsoft::ReactNative::IReactPropertyBag ReactContext::Properties() noex

void ReactContext::CallJSFunction(std::string &&module, std::string &&method, folly::dynamic &&params) noexcept {
if (auto instance = m_reactInstance.GetStrongPtr()) {
if (instance->State() == ReactInstanceState::Loaded) {
if (auto fbInstance = instance->GetInnerInstance()) {
fbInstance->callJSFunction(std::move(module), std::move(method), std::move(params));
}
}
instance->CallJsFunction(std::move(module), std::move(method), std::move(params));
}
}

void ReactContext::DispatchEvent(int64_t viewTag, std::string &&eventName, folly::dynamic &&eventData) noexcept {
if (auto instance = m_reactInstance.GetStrongPtr()) {
if (instance->State() == ReactInstanceState::Loaded) {
instance->DispatchEvent(viewTag, std::move(eventName), std::move(eventData));
}
instance->DispatchEvent(viewTag, std::move(eventName), std::move(eventData));
}
}

Expand Down Expand Up @@ -371,6 +365,7 @@ void ReactInstanceWin::LoadJSBundles() noexcept {
instanceWrapper->loadBundleSync(Mso::Copy(options.Identity));
} catch (...) {
strongThis->m_state = ReactInstanceState::HasError;
strongThis->AbandonJSCallQueue();
strongThis->OnReactInstanceLoaded(Mso::ExceptionErrorProvider().MakeErrorCode(std::current_exception()));
return;
}
Expand All @@ -390,8 +385,10 @@ void ReactInstanceWin::OnReactInstanceLoaded(const Mso::ErrorCode &errorCode) no
strongThis->m_isLoaded = true;
if (!errorCode) {
strongThis->m_state = ReactInstanceState::Loaded;
strongThis->DrainJSCallQueue();
} else {
strongThis->m_state = ReactInstanceState::HasError;
strongThis->AbandonJSCallQueue();
}

if (auto onLoaded = strongThis->m_options.OnInstanceLoaded.Get()) {
Expand All @@ -414,6 +411,8 @@ Mso::Future<void> ReactInstanceWin::Destroy() noexcept {
}

m_isDestroyed = true;
m_state = ReactInstanceState::Unloaded;
AbandonJSCallQueue();

if (!m_isLoaded) {
OnReactInstanceLoaded(Mso::CancellationErrorProvider().MakeErrorCode(true));
Expand Down Expand Up @@ -583,6 +582,7 @@ std::function<void(std::string)> ReactInstanceWin::GetErrorCallback() noexcept {

void ReactInstanceWin::OnErrorWithMessage(const std::string &errorMessage) noexcept {
m_state = ReactInstanceState::HasError;
AbandonJSCallQueue();

if (m_redboxHandler && m_redboxHandler->isDevSupportEnabled()) {
ErrorInfo errorInfo;
Expand Down Expand Up @@ -636,24 +636,63 @@ void ReactInstanceWin::OnDebuggerAttach() noexcept {
m_updateUI();
}

void ReactInstanceWin::DrainJSCallQueue() noexcept {
// Handle all items in the queue one by one.
for (;;) {
JSCallEntry entry; // To avoid callJSFunction under the lock
{
std::scoped_lock lock{m_mutex};
if (m_state == ReactInstanceState::Loaded && !m_jsCallQueue.empty()) {
entry = std::move(m_jsCallQueue.front());
m_jsCallQueue.pop_front();
} else {
break;
}
}

if (auto instance = m_instance.LoadWithLock()) {
instance->callJSFunction(std::move(entry.ModuleName), std::move(entry.MethodName), std::move(entry.Args));
}
}
}

void ReactInstanceWin::AbandonJSCallQueue() noexcept {
std::deque<JSCallEntry> jsCallQueue; // To avoid destruction under the lock
{
std::scoped_lock lock{m_mutex};
if (m_state == ReactInstanceState::HasError || m_state == ReactInstanceState::Unloaded) {
jsCallQueue = std::move(m_jsCallQueue);
}
}
}

void ReactInstanceWin::CallJsFunction(
std::string &&moduleName,
std::string &&method,
folly::dynamic &&params) noexcept {
// callJSFunction can be called from any thread. The native bridge will post the call to the right queue internally.
if (m_state == ReactInstanceState::Loaded) {
bool shouldCall{false}; // To call callJSFunction outside of lock
{
std::scoped_lock lock{m_mutex};
if (m_state == ReactInstanceState::Loaded && m_jsCallQueue.empty()) {
shouldCall = true;
} else if (
m_state == ReactInstanceState::Loading || m_state == ReactInstanceState::WaitingForDebugger ||
(m_state == ReactInstanceState::Loaded && !m_jsCallQueue.empty())) {
m_jsCallQueue.push_back(JSCallEntry{std::move(moduleName), std::move(method), std::move(params)});
}
// otherwise ignore the call
}

if (shouldCall) {
if (auto instance = m_instance.LoadWithLock()) {
instance->callJSFunction(std::move(moduleName), std::move(method), std::move(params));
}
}
}

void ReactInstanceWin::DispatchEvent(int64_t viewTag, std::string &&eventName, folly::dynamic &&eventData) noexcept {
if (m_state == ReactInstanceState::Loaded) {
if (auto instance = m_instanceWrapper.LoadWithLock()) {
instance->DispatchEvent(viewTag, eventName, std::move(eventData));
}
}
folly::dynamic params = folly::dynamic::array(viewTag, std::move(eventName), std::move(eventData));
CallJsFunction("RCTEventEmitter", "receiveEvent", std::move(params));
}

facebook::react::INativeUIManager *ReactInstanceWin::NativeUIManager() noexcept {
Expand Down
10 changes: 10 additions & 0 deletions vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ class ReactInstanceWin final : public Mso::ActiveObject<IReactInstanceInternal,
friend struct LoadedCallbackGuard;
void OnReactInstanceLoaded(const Mso::ErrorCode &errorCode) noexcept;

void DrainJSCallQueue() noexcept;
void AbandonJSCallQueue() noexcept;

struct JSCallEntry {
std::string ModuleName;
std::string MethodName;
folly::dynamic Args;
};

#if defined(USE_V8)
static std::string getApplicationLocalFolder();
#endif
Expand Down Expand Up @@ -162,6 +171,7 @@ class ReactInstanceWin final : public Mso::ActiveObject<IReactInstanceInternal,
Mso::CntPtr<react::uwp::AppearanceChangeListener> m_appearanceListener;
std::string m_bundleRootPath;
Mso::DispatchQueue m_uiQueue;
std::deque<JSCallEntry> m_jsCallQueue;
};

} // namespace Mso::React