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

Invalid cast of CPListItem to CPListImageRowItem #15622

Closed
janwiebe-jump opened this issue Aug 4, 2022 · 4 comments
Closed

Invalid cast of CPListItem to CPListImageRowItem #15622

janwiebe-jump opened this issue Aug 4, 2022 · 4 comments
Labels
need-attention An issue requires our attention/response
Milestone

Comments

@janwiebe-jump
Copy link
Contributor

janwiebe-jump commented Aug 4, 2022

As a continuation of #9996 here is a new issue.

Steps to Reproduce

  1. Use below SceneDelegate as a CarPlay scene delegate
  2. Load the app, and tap on an image of the horizontal row
  3. Get the exception

Expected Behavior

CPNowPlaying should be pushed to the stack and shown.

Actual Behavior

Exception:

Unable to cast object of type 'CarPlay.CPListItem' to type 'CarPlay.CPListImageRowItem'.
at ObjCRuntime.Runtime.GetNSObject[T] (System.IntPtr ptr) [0x00135] in <c07d1d2ff2fb499fb8eca9a33aeb3c2e>:0
  at ObjCRuntime.Trampolines+SDCPListImageRowItemHandler.Invoke (System.IntPtr block, System.IntPtr item, System.nint index, System.IntPtr completionBlock) [0x00016] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/ObjCRuntime/Trampolines.g.cs:1635 
at (wrapper native-to-managed) ObjCRuntime.Trampolines+SDCPListImageRowItemHandler.Invoke(intptr,intptr,System.nint,intptr)
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:85 
at MyApp.iOS.Application.Main (System.String[] args) [0x00001] in /Users/user1/projects/MyApp/app/MyApp/MyApp.iOS/Main.cs:17

If I remove the await Task.Delay() call, it seems to work, but I need to do my async network calls to retrieve the actual data that is shown in the lists.

Environment

Version information
Visual Studio Community 2022 for Mac
Version 17.0.7 (build 7)
Installation UUID: 27bbd976-eba9-4528-9992-1e828471fd34

Runtime
.NET 6.0.5 (64-bit)
Architecture: Arm64

Roslyn (Language Service)
4.1.0-3.22075.3+592501cbb9c9394072a245c15b3458ff88155d85

NuGet
Version: 6.0.0.262

.NET SDK (Arm64)
SDK: /usr/local/share/dotnet/sdk/6.0.302/Sdks
SDK Versions:
	6.0.400-preview.22330.6
	6.0.302
MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET SDK (x64)
SDK Version: 3.1.421

.NET Runtime (Arm64)
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	6.0.7
	6.0.6

.NET Runtime (x64)
Runtime: /usr/local/share/dotnet/x64/dotnet
Runtime Version: 3.1.27

Xamarin.Profiler
Version: 1.8.0.19
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater
Version: 11

Apple Developer Tools
Xcode 13.4.1 (20504)
Build 13F100

Xamarin.Mac
Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

Xamarin.iOS
Version: 15.10.0.5 (Visual Studio Community)
Hash: 96b3edb6d
Branch: d17-2
Build date: 2022-05-18 07:32:07-0400

Xamarin Designer
Version: 17.1.5.90
Hash: 53f47efde
Branch: remotes/origin/d17-0-vsmac
Build date: 2022-07-20 22:42:03 UTC

Xamarin.Android
Version: 12.3.3.3 (Visual Studio Community)
Commit: xamarin-android/d17-2/4e061b7
Android SDK: /Users/janwiebe/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		12.0 (API level 31)
		11.0 (API level 30)

SDK Command-line Tools Version: 5.0
SDK Platform Tools Version: 31.0.3
SDK Build Tools Version: 30.0.3

Build Information: 
Mono: dffa5ab
Java.Interop: xamarin/java.interop/d17-2@9760f0a9
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.38.2@7b1e016
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-2@fc3c2ac

Microsoft Build of OpenJDK
Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk
11.0.12
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK
Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk
1.8.0.302
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager
Version: 17.2.0.37
Hash: 7f5a6ef
Branch: remotes/origin/d17-2
Build date: 2022-07-20 22:42:07 UTC

Android Device Manager
Version: 0.0.0.1116
Hash: e47e6c8
Branch: remotes/origin/d17-2
Build date: 2022-07-20 22:42:07 UTC

Build Information
Release ID: 1700070007
Git revision: 5a924af5432fc0ed4adc294eb2edb6a95c97cf2e
Build date: 2022-07-20 22:39:54+00
Build branch: release-17.0
Build lane: release-17.0

Operating System
Mac OS X 12.5.0
Darwin 21.6.0 Darwin Kernel Version 21.6.0
    Sat Jun 18 17:07:22 PDT 2022
    root:xnu-8020.140.41~1/RELEASE_ARM64_T6000 arm64

Build Logs

Example Project (If Possible)

CarPlaySceneDelegate.txt

@chamons
Copy link
Contributor

chamons commented Aug 4, 2022

Thanks for the feedback.

Please attach a full sample project, as CarPlay is sufficiently complex to setup a project for, and the configuration might cause different behavior.

@chamons chamons added the need-info Waiting for more information before the bug can be investigated label Aug 4, 2022
@chamons chamons added this to the Future milestone Aug 4, 2022
@ghost
Copy link

ghost commented Aug 4, 2022

Hi @janwiebe-jump. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

janwiebe-jump added a commit to janwiebe-jump/carplay-repro that referenced this issue Aug 4, 2022
@janwiebe-jump
Copy link
Contributor Author

Hi @chamons,

Thanks for your quick response.
I stripped down my app to the bare minimum: it's a Xamarin Forms app, with CarPlay side.
https://github.com/janwiebe-jump/carplay-repro

The one thing you need to do is to have a provisioning profile with the carplay entitlement enabled, and set you own provisioning profile and signing certificate in the options.
When you launch the mobile app, you only see a Welcome message.
The CarPlay app shows a CPListTemplate with a row with 4 images. Tapping one of the images triggers the Exception.
Please let me know if I can be of further help.

Thanks for looking into it!

@ghost ghost added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Aug 4, 2022
rolfbjarne added a commit that referenced this issue Aug 22, 2022
As discussed in #9996 the CPListSection constructors are not fully correct, since the CPListImageRowItem can't be added to it, which is possible in the native iOS SDK.
This PR fixes that. With that, also #15622 seems to be fixed.

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
Co-authored-by: Chris Hamons <chris.hamons@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
@rolfbjarne
Copy link
Member

Fixed in #15642.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
need-attention An issue requires our attention/response
Projects
None yet
Development

No branches or pull requests

3 participants