Skip to content

Fixes for the E2E Unpackaged scenario#1431

Closed
danielayala94 wants to merge 10 commits intoWNP_LRPfrom
WNP_LRP_E2E_fixes
Closed

Fixes for the E2E Unpackaged scenario#1431
danielayala94 wants to merge 10 commits intoWNP_LRPfrom
WNP_LRP_E2E_fixes

Conversation

@danielayala94
Copy link
Copy Markdown
Contributor

@danielayala94 danielayala94 commented Sep 16, 2021

While doing extensive testing for the unpackaged apps E2E scenario, I caught a couple of bugs:

1. Bug on foreground notifications: On platform initialization, if the app list size is 0, the NotificationListenerManager was never initialized with a ForegroundSinkManager. Even after adding a listener, the ForegroundSinkManager reference on NotificationListenerManager remained empty. Now we initialize the NotificationListenerManager appropriately regardless of the app list size.
2. NotificationSink update bug: Whenever a channel request arrives, wpncore cleans the corresponding NotificationSink of the app. In such case, the LRP doesn't know if the NotificationSink (a NotificationListener in LRP jargon) is still valid. This caused new push notifications to be dropped and block the channel. With the fix, whenever RegisterForegroundActivator or RegisterLongRunningActivator are called, we remove the existing NotificationListener and replace it with a new one, doing a best effort to have an up-to-date listener. This may still require a RegisterLongRunningActivator call from WAS channel request, if applicable.

@ghost ghost added the needs-triage label Sep 16, 2021
@danielayala94 danielayala94 added the area-Notifications Toast notification, badges, Live Tiles, push notifications label Sep 16, 2021
Copy link
Copy Markdown
Contributor

@loneursid loneursid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All unpackaged unit tests are failing on this PR and needs to be addressed.

@pmpurifoy
Copy link
Copy Markdown
Contributor

All unpkg tests are working now.

PushNotificationChannelManager channelManager{};
winrt::PushNotificationChannel pushChannelReceived{ co_await channelManager.CreatePushNotificationChannelForApplicationAsync(unpackagedAppUserModelId.get()) };

auto notificationPlatform{ wil::CoCreateInstance<NotificationsLongRunningPlatform, INotificationsLongRunningPlatform>(CLSCTX_LOCAL_SERVER) };
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move this block to a helper function.

Comment thread dev/PushNotifications/PushNotificationManager.cpp Outdated
// Command line format: ----WindowsAppRuntimePushServer:-Payload:"<payloadAsEscapedUriFormat>"
std::wstring commandLine = L"----WindowsAppRuntimePushServer:-Payload:\"";
std::string commandLine = "----WindowsAppRuntimePushServer:-Payload:\"";
commandLine.append(reinterpret_cast<char*>(payload), payloadLength);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we re-introducing this escape character bug? @danielayala94 ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saw something like this in the other PR as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmpurifoy Please look at the existing code in WNP_LRP. This seems to be an incorrect merge.

}
CATCH_RETURN()

const std::string NotificationListener::ConvertProcessNameToUtf8String()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed. Just use the helper method provided by @sharath2727 in his PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this method and just call his Helper with m_processName wherever needed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the helper method provided by @sharath2727 Sharath Manchala FTE in his PR.

link?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function was used before the Protocol activation fixes. @pmpurifoy needs to fix the merge with WNP_LRP (i.e. remove this function).

STDMETHOD(OnRawNotificationReceived)(unsigned int payloadLength, _In_ byte* payload, _In_ HSTRING correlationVector) noexcept;

private:
const std::string ConvertProcessNameToUtf8String();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove. Not needed. Use @sharath2727 's helper method

Copy link
Copy Markdown
Member

@jonwis jonwis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but please apply @hulumane 's feedback.

// Command line format: ----WindowsAppRuntimePushServer:-Payload:"<payloadAsEscapedUriFormat>"
std::wstring commandLine = L"----WindowsAppRuntimePushServer:-Payload:\"";
std::string commandLine = "----WindowsAppRuntimePushServer:-Payload:\"";
commandLine.append(reinterpret_cast<char*>(payload), payloadLength);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saw something like this in the other PR as well.

shellExecuteInfo.nShow = SW_NORMAL;

if (!ShellExecuteEx(&shellExecuteInfo))
if (!ShellExecuteExA(&shellExecuteInfo))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New code should use the -W variants. Why the shift to -A?

@loneursid loneursid self-requested a review September 30, 2021 01:09
@loneursid
Copy link
Copy Markdown
Contributor

loneursid commented Sep 30, 2021

All unpkg tests are working now.

Verified. They do indeed all pass now - as long as you have this FrameworkUDK fix installed on your devide: https://microsoft.visualstudio.com/OS/_git/os.2020/pullrequest/6502196

thanks.

@loneursid loneursid dismissed their stale review September 30, 2021 01:16

Verified all unit tests passing, given the patched frameworkUDK is installed on the device.

Copy link
Copy Markdown
Contributor Author

@danielayala94 danielayala94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmpurifoy I cannot block the PR because I opened it. But please do a thorough review of all files edited on this PR against the current WNP_LRP code. I noticed that NotificationListener is missing part of the fixes for Protocol.

Copy link
Copy Markdown
Contributor

@loneursid loneursid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch cannot be merged into WNP_LRP in its current state, as would regress other changes. It seems that WNP_LRP was merged, then the merge was reverted. This means that if this branch is merged into WNP_LRP as is, we'll regress previous changes. Furthermore, if WNP_LRP was then merged into main, the regression would propagate to main. (the branch is currently bringing changes to 182 files, most of them outside of the Notifications firectories..., this isn't good at all)

@pmpurifoy, please work with @jonwis to see what is the correct solution here. I've the feeling that this branch will have to be reset to the initial merge of WNP_LRP or the the commit prior to that. That would mean re-applying the few "nits" PR that have been merged since then (as they would be lost after the reset operation.)

Also note that whatever issues you faced the first time WNP_LRP was merged in this branch, and which prompted the revert, will have to be adressed sooner or later. This branch will have to be merged into WNP_LRP at some point and that merge will need to be clean and not introduce any unwanted side-effects.

@pmpurifoy
Copy link
Copy Markdown
Contributor

Moving PR here: #1543

@pmpurifoy pmpurifoy closed this Oct 6, 2021
@bpulliam bpulliam deleted the WNP_LRP_E2E_fixes branch November 7, 2023 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Notifications Toast notification, badges, Live Tiles, push notifications needs-triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants