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

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Nov 5, 2019

The previous pr fails luci post submit. This should fixes the test failure

@chunhtai chunhtai requested a review from xster November 5, 2019 00:20
@chunhtai chunhtai added the CQ+1 label Nov 5, 2019
- (void)setViewController:(FlutterViewController*)viewController {
FML_DCHECK(self.iosPlatformView);
_viewController = [viewController getWeakPtr];
_viewController = viewController ? [viewController getWeakPtr] : fml::WeakPtr<FlutterViewController>();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes the local failure

[_flutterViewControllerWillDeallocObserver release];
}

if (viewController) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes luci failure

- (void)setViewController:(FlutterViewController*)viewController {
FML_DCHECK(self.iosPlatformView);
_viewController = [viewController getWeakPtr];
_viewController = viewController ? [viewController getWeakPtr] : fml::WeakPtr<FlutterViewController>();
Copy link
Member

Choose a reason for hiding this comment

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

This LGTM, but what was happening previously? Calling getWeakPtr on nil when we're unsetting it actually produces a WeakPtr instance which crashes on .get()?

@dnfield might have some opinions too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

viewController is nil with type FlutterViewController. We call the WeakPtrFactory on a undefined reference which try to wrap itself. I guess it just some garbage, and observation will break the compiler for some reason which prevent me from observe what is inside.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

schrodinger's cat

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm. Sending a message to nil results in nil. But we expect the weak ptr to be a reference. I think this is ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I tried viewController.get(), it does try to grab what is inside except it fails the thread check. I am not familiar with objective c. If viewController is nil, will viewController.get() still work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is a driver test calls this


and it only happens in my local machine. I believe it is passing luci because somehow the platform thread shared the same thread as driver test?

Copy link
Member

Choose a reason for hiding this comment

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

Can we check (via xcode debugger or something) whether the remaining issue is indeed a threading issue? If so, let's use the right threads in the test via something like https://github.com/flutter/engine/blob/master/fml/synchronization/count_down_latch_unittests.cc#L24

Copy link
Member

Choose a reason for hiding this comment

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

We end up doing something similar on Android too when running instrumentation tests (which drives from a different thread while the engine expects main thread access). https://github.com/flutter/engine/blob/master/testing/scenario_app/android/app/src/androidTest/java/dev/flutter/scenarios/EngineLaunchE2ETest.java

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the code here is correct. The weakptr is created in test thread and unwrapped in the same thread. It is because the nil vc will cause some issue.
consider this case

FlutterViewController* testvc = nil;
fml::WeakPtr<FlutterViewController> test = [testvc getWeakPtr];

I believed [testvc getWeakPtr] will return a static_cast<fml::WeakPtr> version of nil. this will result in a unintialized weakptr whose creating thread is 0x0;
When you later do test.get(), it tries to compare creating thread 0x0 with current thread and failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

either way, I think this is tangential to this pr.

@xster
Copy link
Member

xster commented Nov 5, 2019

LGTM. Thanks for digging into this one!!

@chunhtai chunhtai merged commit 1bfb928 into flutter:master Nov 5, 2019
chunhtai added a commit to chunhtai/engine that referenced this pull request Nov 6, 2019
chunhtai added a commit to chunhtai/engine that referenced this pull request Nov 6, 2019
chunhtai added a commit that referenced this pull request Nov 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants