Skip to content

Commit

Permalink
iOS tv-casting-app: Apply StackLocks and sequence callbacks (#26817)
Browse files Browse the repository at this point in the history
* V1.0.0 branch 25023 fix (#110)

* Lock the SDK before interacting with it.

[Problem]

The Matter SDK assumes that the client will take a lock on the SDK prior to
interacting with any APIs. There is 1 Android function and several iOS functions
that do not take the lock prior to interacting with the SDK APIs.

There are also some functions that invoke the Matter SDK in a way that may
result in out-of-order callback invocation (e.g. the conceptual "started"
callback may be invoked after the conceptual "ended" callback).

[Solution]

Create utility functions that help ensure that the Matter SDK is invoked safely
and that callbacks are delivered in the correct order.

[Testing]

Performed local, manual testing with the 'tv-casting-app' example on iOS against
a Raspberry Pi running the 'tv-app'. Ran the certification test in the
'tv-casting-app' on iOS against the same Raspberry Pi.

* * Updating naming and parameter order for new CastingServerBridge APIs
* Refactored the Certification Tests to more fully exercise threading behavior

* * Updating the documentation for modified APIs

* Restyling

---------

Co-authored-by: Michael Douglas <125094815+domichae-amazon@users.noreply.github.com>
  • Loading branch information
2 people authored and pull[bot] committed Feb 8, 2024
1 parent 84e1bd2 commit 1353005
Show file tree
Hide file tree
Showing 7 changed files with 2,133 additions and 1,774 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Copyright (c) 2020-2022 Project CHIP Authors
* Copyright (c) 2020-2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -102,7 +102,7 @@
@return Onboarding payload
*/
- (OnboardingPayload * _Nonnull)getOnboardingPaylod;
- (OnboardingPayload * _Nonnull)getOnboardingPayload;

/*!
@brief Request opening of a basic commissioning window
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CommissionerDiscoveryDelegateImpl : public chip::Controller::DeviceDiscove
public:
void SetUp(dispatch_queue_t _Nonnull clientQueue,
void (^_Nonnull objCDiscoveredCommissionerHandler)(DiscoveredNodeData * _Nonnull),
TargetVideoPlayerInfo * cachedTargetVideoPlayerInfos)
TargetVideoPlayerInfo * _Nullable cachedTargetVideoPlayerInfos)
{
mClientQueue = clientQueue;
mObjCDiscoveredCommissionerHandler = objCDiscoveredCommissionerHandler;
Expand Down Expand Up @@ -59,7 +59,7 @@ class CommissionerDiscoveryDelegateImpl : public chip::Controller::DeviceDiscove
private:
void (^_Nonnull mObjCDiscoveredCommissionerHandler)(DiscoveredNodeData * _Nonnull);
dispatch_queue_t _Nonnull mClientQueue;
TargetVideoPlayerInfo * mCachedTargetVideoPlayerInfos;
TargetVideoPlayerInfo * _Nullable mCachedTargetVideoPlayerInfos;
};

#endif /* CommissionerDiscoveryDelegateImpl_h */
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/**
*
* Copyright (c) 2020-2022 Project CHIP Authors
* Copyright (c) 2020-2023 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,7 @@ import SwiftUI
struct CertTestView: View {
@StateObject var viewModel = CertTestViewModel()
@State private var targetContentAppId: String = ""
@State private var parallelizeTests = true

var body: some View {
VStack(alignment: .leading) {
Expand All @@ -46,9 +47,17 @@ struct CertTestView: View {
}
.border(.secondary)
}
HStack() {
Toggle(isOn: $parallelizeTests) {
Text("Parallelize Tests")
}
}

Button("Launch Test") {
viewModel.launchTest(targetContentAppId: targetContentAppId)
viewModel.launchTests(
targetContentAppId: targetContentAppId,
inParallel: parallelizeTests
)
}
.background(Color.blue)
.foregroundColor(Color.white)
Expand Down
Loading

0 comments on commit 1353005

Please sign in to comment.