mapbox-maps-flutter icon indicating copy to clipboard operation
mapbox-maps-flutter copied to clipboard

PlatformException recreating_view

Open jnorkus opened this issue 1 year ago • 24 comments

After upgrading to Flutter 3.27.0 I am getting this error on an iOS simulator (haven't tested on a device) after hot restarting. Also, the map view does not properly load.

Unhandled Exception: PlatformException(recreating_view, trying to create an already created view, view id: '0', null)

jnorkus avatar Dec 16 '24 14:12 jnorkus

Hi @jnorkus, I can't reproduce the issue with Flutter 3.27, could you share a code snippet?

evil159 avatar Dec 19 '24 09:12 evil159

Hi! I’m also experiencing the same issue after upgrading to Flutter 3.27.0, specifically when performing a hot restart on the iOS simulator.

flutter: ══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════
flutter: The following PlatformException was thrown:
flutter: PlatformException(recreating_view, trying to create an already created view, view id: '0', null)
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:646:7)
flutter: #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
flutter: <asynchronous suspension>
flutter: #2      PlatformViewsService.initUiKitView (package:flutter/src/services/platform_views.dart:248:5)
flutter: <asynchronous suspension>
flutter: #3      _DarwinViewState._createNewUiKitView (package:flutter/src/widgets/platform_view.dart:921:36)
flutter: <asynchronous suspension>
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════

MPinto16 avatar Dec 19 '24 13:12 MPinto16

Hi @jnorkus, I can't reproduce the issue with Flutter 3.27, could you share a code snippet?

I was able to reproduce using the example project.

  1. Run on iOS simulator
  2. Go to "Display a simple map"
  3. Do a hot restart
  4. Go to "Display a simple map"

jnorkus avatar Dec 19 '24 13:12 jnorkus

@jnorkus thank you for the clarification, still no luck on my side replicating this, could you share iOS and Xcode version you are using?

evil159 avatar Dec 19 '24 15:12 evil159

@jnorkus thank you for the clarification, still no luck on my side replicating this, could you share iOS and Xcode version you are using?

iOS 17.2 Xcode 15.2

I'll try upgrading my macOS to get the latest version of Xcode and see if that helps.

jnorkus avatar Dec 20 '24 14:12 jnorkus

Same results on: iOS 18.2 Xcode 16.2

Reproducable on the example app in this repo as before. Please note that you have to do a hot restart (not hot reload).

jnorkus avatar Dec 23 '24 10:12 jnorkus

I got the same issue, and just so you know downgrading to flutter v3.24.5 solved the issue. Do you need help to reproduce @evil159?

ludovicjamet avatar Jan 06 '25 08:01 ludovicjamet

Same issue

Flutter (Channel stable, 3.27.1, on macOS 15.2 24C101 darwin-x64, locale en-GB)
    • Flutter version 3.27.1 on channel stable at /Users/user/development/fluttersdk
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 17025dd882 (3 weeks ago), 2024-12-17 03:23:09 +0900
    • Engine revision cb4b5fff73
    • Dart version 3.6.0
    • DevTools version 2.40.2

KonstantinDubrouski avatar Jan 09 '25 11:01 KonstantinDubrouski

I've got the same issue on MapBox 2.4.0, Xcode 16.0

Flutter 3.27.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 17025dd882 (3 weeks ago) • 2024-12-17 03:23:09 +0900
Engine • revision cb4b5fff73
Tools • Dart 3.6.0 • DevTools 2.40.2

jasperdemmers avatar Jan 09 '25 11:01 jasperdemmers

Same issue wit flutter 3.27.1

Ekram-Muahammad avatar Jan 11 '25 08:01 Ekram-Muahammad

Seems to be a bug in Flutter itself https://github.com/flutter/flutter/issues/110381

evil159 avatar Jan 14 '25 09:01 evil159

Any news on this one, is it really a Flutter issue?

ludovicjamet avatar Feb 08 '25 22:02 ludovicjamet

Any news ? Starting to happen with flutter 3.27.X

GamxXamg avatar Feb 22 '25 16:02 GamxXamg

Today was merge a solution I think https://github.com/flutter/flutter/issues/163935, but is just for iOS

favazHF avatar Mar 05 '25 02:03 favazHF

There were two separate fixes, one for iOS and one for macOS. Both have been merged to main. They should be available in the next major Flutter release.

macOS: https://github.com/flutter/flutter/issues/110381 iOS: https://github.com/flutter/flutter/issues/163935

PaulAllanSturm avatar Mar 05 '25 20:03 PaulAllanSturm

I am facing this issue when debugging on iPhone 13 Pro with flutter 3.29.1

[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(recreating_view, trying to create an already created view, view id: '8', null) #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7) message_codecs.dart:652 #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:370:18) platform_channel.dart:370 #2 PlatformViewsService.initUiKitView (package:flutter/src/services/platform_views.dart:243:5) platform_views.dart:243 #3 _DarwinViewState._createNewUiKitView (package:flutter/src/widgets/platform_view.dart:933:36) platform_view.dart:933

using google map widget like this " SizedBox( width: 100, height: 100, child: GoogleMap( initialCameraPosition: CameraPosition( target: LatLng(address.latitude, address.longitude), zoom: 14, ), zoomControlsEnabled: false, scrollGesturesEnabled: false, tiltGesturesEnabled: false, rotateGesturesEnabled: false, myLocationButtonEnabled: false, ), ),"

upgrading to flutter 3.29.2 and will test

Salimer avatar Mar 15 '25 10:03 Salimer

Still same issue on flutter 3.29.2, I added unique keys but still.

Salimer avatar Mar 15 '25 11:03 Salimer

The fixes are in release 3.30.0-0.1.pre (the 3.30 beta release). They'll also be in the next major stable release, which will be presumably 3.31 or 3.32.

PaulAllanSturm avatar Mar 15 '25 15:03 PaulAllanSturm

Still same issue on Flutter 3.29.2 • channel stable, waiting for stable release 3.31+

moorphism-ltd avatar Mar 21 '25 02:03 moorphism-ltd

Same issue on Flutter 3.29.1. This error seems to be very specific to embedded views like maps or iframes. I get the error in a Mac app using the flutter_inappwebview package, and I get the same error using maps on iOS. It may be specific to iOS and macOS.

I also find that when I reload several times, the number of IDs increases until I find one that works correctly after several refreshes.

PlatformException(recreating_view, trying to create an already created view, view id: '1 or 2 or 3 or 4 ... n', null)

I'm waiting for the new version. It seems they've already fixed it, but it hasn't been merged into the main version yet. Hopefully it'll be fixed soon.

andrescastane avatar Mar 26 '25 12:03 andrescastane

update?

niteshneupane avatar Apr 01 '25 11:04 niteshneupane

Is there any update regarding this topic?

pavleralic avatar Apr 19 '25 19:04 pavleralic

The underlying bug in Flutter was fixed in Flutter 3.30 (beta). It's not being backported to the 3.29 series. You have the option of using the latest Flutter beta, which is Flutter 3.32. Or waiting for whatever the next major stable release will be, which might be Flutter 3.33.

PaulAllanSturm avatar Apr 19 '25 20:04 PaulAllanSturm

I'm facing the same issue. It seems to be a Flutter related problem rather than a Mapbox.

RoyalBosS-Ayush avatar May 04 '25 10:05 RoyalBosS-Ayush