Skip to content

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

Closed
@xujunquan

Description

@xujunquan

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!

Activity

xujunquan

xujunquan commented on Jul 30, 2019

@xujunquan
Author

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

changed the title [-]Multiple Entry flutterVC and pop [flutterViewController dealloc] crashed[/-] [+]flutterViewController Multiple Entry and pop, [flutterViewController dealloc] crashed[/+] on Jul 30, 2019
added
a: existing-appsIntegration with existing apps via the add-to-app flow
c: crashStack traces logged to the console
platform-iosiOS applications specifically
on Jul 30, 2019
blasten

blasten commented on Jul 30, 2019

@blasten
added
engineflutter/engine repository. See also e: labels.
on Jul 30, 2019
xster

xster commented on Jul 30, 2019

@xster
Member

What is the crash trace and error?

xujunquan

xujunquan commented on Jul 31, 2019

@xujunquan
Author

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

xster commented on Jul 31, 2019

@xster
Member

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

guangmingzizai

guangmingzizai commented on Jul 31, 2019

@guangmingzizai

I also run into the same problem, any solution?

mekhi

mekhi commented on Aug 2, 2019

@mekhi

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

xujunquan commented on Aug 5, 2019

@xujunquan
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

xster commented on Aug 6, 2019

@xster
Member

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

10 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: existing-appsIntegration with existing apps via the add-to-app flowc: crashStack traces logged to the consoleengineflutter/engine repository. See also e: labels.platform-iosiOS applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @chinmaygarde@xster@jmagman@blasten@guangmingzizai

        Issue actions

          flutterViewController Multiple Entry and pop, [flutterViewController dealloc] crashed · Issue #37225 · flutter/flutter