Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutterViewController Multiple Entry and pop, [flutterViewController dealloc] crashed #37225

Closed
xujunquan opened this issue Jul 30, 2019 · 13 comments
Labels
a: existing-apps Integration with existing apps via the add-to-app flow c: crash Stack traces logged to the console engine flutter/engine repository. See also e: labels. platform-ios iOS applications specifically

Comments

@xujunquan
Copy link

xujunquan commented Jul 30, 2019

init flutter

FlutterViewController *flutter = FlutterViewController.new;
[flutter setInitialRoute:router];
[nav pushViewController:flutter animated:YES];

scene
native1->flutter1->native2->flutter2
then pop
when flutter1 poped [flutterViewController dealloc] crashed

flutter git:(stable) flutter doctor -v
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale zh-Hans-CN)
    • Flutter version 1.7.8+hotfix.4 at xxx
    • Framework revision 20e59316b8 (11 天前), 2019-07-18 20:04:33 -0700
    • Engine revision fee001c93f
    • Dart version 2.4.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at xxx
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.6.1

[✓] iOS tools - develop for iOS devices
    • ios-deploy 1.9.4

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 37.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] Connected device (2 available)
    xx
    • iPhone X      • 2456ECF0-BB8E-4633-B3E7-140A1939CA0A     • ios •
      com.apple.CoreSimulator.SimRuntime.iOS-12-4 (simulator)

• No issues found!
@xujunquan
Copy link
Author

xujunquan commented Jul 30, 2019

i use /Users/name/flutter/dev/integration_tests/ios_add2app this project to test

i only edit this file

`implementation FullScreenViewController

  • (void)viewWillDisappear:(BOOL)animated {

    [super viewWillDisappear:animated];

    self.navigationController.navigationBarHidden = NO;
    self.navigationController.hidesBarsOnSwipe = NO;
    if (self.isMovingFromParentViewController) {
    // Note that if we were doing things that might cause the VC
    // to disappear (like using the image_picker plugin)
    // we shouldn't do this. But in this case we know we're
    // just going back to the navigation controller.
    // If we needed Flutter to tell us when we could actually go away,
    // we'd need to communicate over a method channel with it.
    [self.engine setViewController:nil];
    }
    }

  • (void)viewDidLoad {
    [super viewDidLoad];

    UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:@"next" style:UIBarButtonItemStylePlain target:self action:@selector(next)];
    self.navigationItem.rightBarButtonItem = rightBarItem;
    }

  • (void)next {

    FullScreenViewController *flutterViewController = [[FullScreenViewController alloc] init];
    [flutterViewController setInitialRoute:@"full"];
    // [[self reloadMessageChannel] sendMessage:@"full"];
    [self.navigationController
    pushViewController:flutterViewController animated:NO];
    }

  • (void)dealloc {

    NSLog(@"dealloc");
    }

end`

run in simulateor will not crash but crashed in many real devices

@xujunquan xujunquan changed the title Multiple Entry flutterVC and pop [flutterViewController dealloc] crashed flutterViewController Multiple Entry and pop, [flutterViewController dealloc] crashed Jul 30, 2019
@blasten blasten added a: existing-apps Integration with existing apps via the add-to-app flow c: crash Stack traces logged to the console platform-ios iOS applications specifically labels Jul 30, 2019
@blasten
Copy link

blasten commented Jul 30, 2019

cc @jmagman @xster

@xster xster added the engine flutter/engine repository. See also e: labels. label Jul 30, 2019
@xster
Copy link
Member

xster commented Jul 30, 2019

What is the crash trace and error?

@xujunquan
Copy link
Author

xujunquan commented Jul 31, 2019

What is the crash trace and error?

Thread 1 Queue : com.apple.main-thread (serial)
#0	0x0000000182990910 in objc_msgSend ()
#1	0x00000001867d96ac in +[EAGLContext setCurrentContext:] ()
#2	0x0000000104a887c4 in flutter::IOSGLRenderTarget::~IOSGLRenderTarget() ()
#3	0x0000000104a894c0 in std::__1::unique_ptr<flutter::IOSGLRenderTarget, std::__1::default_delete<flutter::IOSGLRenderTarget> >::reset(flutter::IOSGLRenderTarget*) ()
#4	0x0000000104a88d40 in flutter::IOSSurfaceGL::~IOSSurfaceGL() ()
#5	0x0000000104a88d70 in flutter::IOSSurfaceGL::~IOSSurfaceGL() ()
#6	0x0000000104a8a140 in flutter::PlatformViewIOS::SetOwnerViewController(fml::WeakPtr<FlutterViewController>) ()
#7	0x0000000104a6bf14 in -[FlutterEngine setViewController:] ()
#8	0x00000001046c4500 in -[FullScreenViewController viewWillDisappear:] at /Users/xxx/flutter/dev/integration_tests/ios_add2app/ios_add2app/FullScreenViewController.m:24
#9	0x000000018d45d79c in -[UIViewController _setViewAppearState:isAnimating:] ()
#10	0x000000018d47b998 in -[UIViewController __viewWillDisappear:] ()
#11	0x000000018d71b424 in -[UINavigationController _startCustomTransition:] ()
#12	0x000000018d48aa4c in -[UINavigationController _startDeferredTransitionIfNeeded:] ()
#13	0x000000018d48a6a4 in -[UINavigationController __viewWillLayoutSubviews] ()
#14	0x000000018d47e3a8 in -[UILayoutContainerView layoutSubviews] ()
#15	0x000000018d3d66f4 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#16	0x000000018794be54 in -[CALayer layoutSublayers] ()
#17	0x000000018794ffe4 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#18	0x00000001878bc6c8 in CA::Context::commit_transaction(CA::Transaction*) ()
#19	0x00000001878e41b0 in CA::Transaction::commit() ()
#20	0x000000018d7af518 in _UIApplicationFlushRunLoopCATransactionIfTooLate ()
#21	0x000000018dd8c5d0 in __handleEventQueueInternal ()
#22	0x000000018dd85368 in __handleHIDEventFetcherDrain ()
#23	0x000000018376b404 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#24	0x000000018376ac2c in __CFRunLoopDoSources0 ()
#25	0x000000018376879c in __CFRunLoopRun ()
#26	0x0000000183688da8 in CFRunLoopRunSpecific ()
#27	0x000000018566e020 in GSEventRunModal ()
#28	0x000000018d6a8758 in UIApplicationMain ()
#29	0x00000001046c34f8 in main at /Users/yiche/flutter/dev/integration_tests/ios_add2app/ios_add2app/main.m:10
#30	0x0000000183119fc0 in start ()

@xster
Copy link
Member

xster commented Jul 31, 2019

Seems related to flutter/engine#7919. Perhaps @chinmaygarde has insights.

@guangmingzizai
Copy link

I also run into the same problem, any solution?

@mekhi
Copy link

mekhi commented Aug 2, 2019

Overriding the dealloc method in a subclass of FlutterViewController, calling[EAGLContext setCurrentContext:nil]can solve this problem.

@interface XXFlutterViewController : FlutterViewController
...
@end

@implementation XXFlutterViewController
...
- (void)dealloc {
    [EAGLContext setCurrentContext:nil];
    ...
}
@end

@xujunquan
Copy link
Author

Seems related to flutter/engine#7919. Perhaps @chinmaygarde has insights.

Overriding the dealloc method in a subclass of FlutterViewController, calling[EAGLContext setCurrentContext:nil]can solve this problem.

@interface XXFlutterViewController : FlutterViewController
...
@end

@implementation XXFlutterViewController
...
- (void)dealloc {
    [EAGLContext setCurrentContext:nil];
    ...
}
@end

非常感谢,测试真机有效,不会闪退了

@xster
Copy link
Member

xster commented Aug 6, 2019

We'd still like to find and solve the root issue. Leaving this bug open.

@xster xster reopened this Aug 6, 2019
@jmagman jmagman added this to Engineer Reviewed in Add-to-app - iOS engine review Jan 9, 2020
@jmagman jmagman moved this from Engineer reviewed to Awaiting triage in Add-to-app - iOS engine review Jan 9, 2020
@jmagman jmagman moved this from Awaiting triage to Triage in Add-to-app - iOS engine review Jan 9, 2020
@gaaclarke gaaclarke moved this from Awaiting triage to Engineer reviewed in Add-to-app - iOS engine review Jan 23, 2020
@jmagman jmagman added this to Awaiting triage in Mobile - iOS engine review Feb 25, 2020
@jmagman jmagman removed this from Awaiting triage in Mobile - iOS engine review Feb 27, 2020
@jmagman jmagman added this to Awaiting triage in Mobile - iOS engine review via automation Mar 5, 2020
@gaaclarke gaaclarke moved this from Awaiting triage to Engineer reviewed in Mobile - iOS engine review Apr 8, 2020
@ChenPingSheng
Copy link

Overriding the dealloc method in a subclass of FlutterViewController, calling[EAGLContext setCurrentContext:nil]can solve this problem.

@interface XXFlutterViewController : FlutterViewController
...
@end

@implementation XXFlutterViewController
...
- (void)dealloc {
    [EAGLContext setCurrentContext:nil];
    ...
}
@end

Can someone write this code into FlutterViewController's dealloc method? It may help many other people like me.

@jmagman
Copy link
Member

jmagman commented Jun 5, 2020

@chinmaygarde You reviewed flutter/engine#17366, is this fixed?

@chinmaygarde
Copy link
Member

Yeah. This has been fixed on ToT.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: existing-apps Integration with existing apps via the add-to-app flow c: crash Stack traces logged to the console engine flutter/engine repository. See also e: labels. platform-ios iOS applications specifically
Projects
Mobile - iOS engine review
  
Engineer reviewed
Add-to-app - iOS engine review
  
Engineer reviewed
Development

No branches or pull requests

8 participants