Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@clarkezone
Copy link

Description

This is the first in a series of patches to add support for a Windows UWP target, embedder implementation and runner per flutter/flutter#14967.

This change adds a new build target which is selected with target os winuwp for example python .\flutter\tools\gn --runtime-mode=debug --unoptimized --winuwp and will build a Windows binary flutter_windows_winuwp.dll. The implementation is stub only but the important aspect of this change is that all win32 specifics are now compiled behind an #ifdef which is only active for the win32 target. Once this PR has landed, the intent is to enable the target in CI to give some level of protection for the UWP target as new win32 functionality and os calls are added.

This change cannot be landed until a small 5 line patch is made to dart to support target_os == "winuwp" which will be opened in due course and referenced here. Until that has happened this change will not build successfully in CI and should be consider WIP although it is ready for review now.

Related Issues

flutter/flutter#14967

Tests

Since this change is a stub, testing has not been added in anything but placeholder form.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the contributor guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the C++, Objective-C, Java style guides for the engine.
  • I read the tree hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.
  • I am willing to follow-up on review comments in a timely manner.

Reviewer Checklist

Breaking Change

Did any tests fail when you ran them? Please read handling breaking changes.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

🤦 I just discovered that this has been sitting here as a draft review for over a week. I thought it was waiting for you to update based on feedback.

switches.begin(), switches.end(), std::back_inserter(argv),
[](const std::string& arg) -> const char* { return arg.c_str(); });

#ifndef FLUTTER_WINUWP
Copy link
Contributor

Choose a reason for hiding this comment

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

For cases where we know we are going to need an equivalent and there's nothing in the interface that's Win32-specific, we should really make an interface class--even if we currently don't have a UWP implementation-rather than scattering ifdefs.

Copy link
Author

Choose a reason for hiding this comment

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

Appols, please can you be more specific?

Copy link
Author

Choose a reason for hiding this comment

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

Anything to do here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I missed this. In particular, I think we should make an abstract TaskRunner class that the current Win32 version inherits from, and with a temporarily-no-op UWP subclass, and then most of the ifdefs about task runners in this file go away (in fact, if we declare a factory method in the abstract class's header, and implement it in each of the subclass files, then we don't need any ifdefs for task runner at all I think.)

Copy link
Author

Choose a reason for hiding this comment

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

I have added an abstract taskrunner, made the win32 version inherit and add the winrt version as well (bonus.. it actually works ;-)). However, I'm not sure how to implement the factory pattern in a way that would eliminate the ifdef from flutter_windows_engine. Since c++ doesn't support virtual static inheritance i assume you are implying using a template function for the factory? If yes, that will not eliminate the need for an ifdef at the calling site. Also, note that there is another ifdef in that file so even if the factory is possible, that file won't be clean. Moving the ifdefs in question up into the caller will merely add ifdefs to a file that doesn't have any currently. So not quite sure what to do about the last aspect of the request here.

Copy link
Author

Choose a reason for hiding this comment

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

Please reopen if you have more thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was envisioning a more low-tech solution:

  • Declare a freestanding CreateTaskRunner function in task_runner.h
  • Implement that function twice, once in the Win32 .cc file, and once in the WinRT .cc file

Since only one of the files will be linked, only one implementation will be present.

@clarkezone
Copy link
Author

One remaining clarifying question. This change is now dependent on a buildroot update: flutter/buildroot#409

@clarkezone clarkezone removed the Work in progress (WIP) Not ready (yet) for review! label Nov 5, 2020
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Mostly just some more small structural cleanup so we're not adding more technical debt; overall seems like a good foundation.

// host app can own its own message loop and flutter still gets to process
// tasks on a timely basis.
class Win32TaskRunner {
class Win32TaskRunner : public TaskRunner {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should really be calling these classes things like TaskRunnerWin32/TaskRunnerWinRt rather than the reverse. Let's fix that for this class in this PR (since it's adding a new file with the naming we should move away from), and I can do a follow-up to clean up the others after it lands.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

I've addressed the comments from my last round of feedback.

@cbracken Since I've taken over the last part of this PR, could you review? I've made significant enough changes that it should get an approval from someone other than me.

@clarkezone
Copy link
Author

@cbracken do you think you might get to this relatively soon? I'm holding off on the next UWP change until this is merged and I can cleanly rebuild the UWP prototype on ToT.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

LGTM with one minor question/suggestion.

// value in a dictionary with the given |key|.
virtual void GetPlainText(
std::unique_ptr<MethodResult<rapidjson::Document>> result,
const char* key) = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Why const char* here rather than std::string_view? Would allow for more flexibility at the call-site. Similarly SetPlainText could take a string_view.

@clarkezone
Copy link
Author

clarkezone commented Dec 4, 2020 via email

@clarkezone clarkezone added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Dec 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants