Skip to content

Commit b465c65

Browse files
committed
feat: poc volt webview
1 parent 6a4e655 commit b465c65

16 files changed

+5782
-4
lines changed

β€Žsample/Assets/Scenes/Passport/WebViewTest.unity

Lines changed: 3808 additions & 0 deletions
Large diffs are not rendered by default.

β€Žsample/Assets/Scenes/Passport/WebViewTest.unity.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žsample/Assets/Scripts/Passport/WebViewTesting.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
using System;
2+
3+
namespace Immutable.Passport.WebViewTesting
4+
{
5+
/// <summary>
6+
/// Interface for WebView adapters to standardize testing across different packages
7+
/// </summary>
8+
public interface IWebViewAdapter : IDisposable
9+
{
10+
/// <summary>
11+
/// Event fired when navigation completes
12+
/// </summary>
13+
event Action<string> OnNavigationCompleted;
14+
15+
/// <summary>
16+
/// Event fired when a message is received from JavaScript
17+
/// </summary>
18+
event Action<string> OnMessageReceived;
19+
20+
/// <summary>
21+
/// Event fired when an error occurs
22+
/// </summary>
23+
event Action<string> OnError;
24+
25+
/// <summary>
26+
/// Whether the WebView is currently active
27+
/// </summary>
28+
bool IsActive { get; }
29+
30+
/// <summary>
31+
/// Initialize the WebView with specified dimensions
32+
/// </summary>
33+
/// <param name="width">Width in pixels</param>
34+
/// <param name="height">Height in pixels</param>
35+
void Initialize(int width, int height);
36+
37+
/// <summary>
38+
/// Navigate to the specified URL
39+
/// </summary>
40+
/// <param name="url">URL to navigate to</param>
41+
void Navigate(string url);
42+
43+
/// <summary>
44+
/// Execute JavaScript in the WebView
45+
/// </summary>
46+
/// <param name="script">JavaScript code to execute</param>
47+
void ExecuteJavaScript(string script);
48+
49+
/// <summary>
50+
/// Send a message to the WebView
51+
/// </summary>
52+
/// <param name="message">Message to send</param>
53+
void SendMessage(string message);
54+
55+
/// <summary>
56+
/// Show the WebView
57+
/// </summary>
58+
void Show();
59+
60+
/// <summary>
61+
/// Hide the WebView
62+
/// </summary>
63+
void Hide();
64+
65+
/// <summary>
66+
/// Get current performance metrics
67+
/// </summary>
68+
/// <returns>Performance data</returns>
69+
WebViewPerformanceMetrics GetPerformanceMetrics();
70+
}
71+
72+
[System.Serializable]
73+
public class WebViewPerformanceMetrics
74+
{
75+
public float memoryUsageMB;
76+
public float cpuUsagePercent;
77+
public float renderTimeMsAvg;
78+
public int textureWidth;
79+
public int textureHeight;
80+
public string engineVersion;
81+
}
82+
}

β€Žsample/Assets/Scripts/Passport/WebViewTesting/IWebViewAdapter.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "Immutable.Passport.WebViewTesting",
3+
"rootNamespace": "Immutable.Passport.WebViewTesting",
4+
"references": [
5+
"Unity.TextMeshPro",
6+
"Immutable.Passport.Runtime.Public",
7+
"Immutable.Passport.Runtime.Private",
8+
"VoltstroStudios.UnityWebBrowser"
9+
],
10+
"includePlatforms": [],
11+
"excludePlatforms": [],
12+
"allowUnsafeCode": false,
13+
"overrideReferences": false,
14+
"precompiledReferences": [],
15+
"autoReferenced": true,
16+
"defineConstraints": [],
17+
"versionDefines": [],
18+
"noEngineReferences": false
19+
}

β€Žsample/Assets/Scripts/Passport/WebViewTesting/Immutable.Passport.WebViewTesting.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
# πŸ§ͺ WebView Testing Framework
2+
3+
This framework provides a standardized way to test different WebView packages for Unity integration with Immutable Passport.
4+
5+
## 🎯 Purpose
6+
7+
- **Compare WebView packages** (Volt Unity Web Browser, Alacrity, UWebView2, ZenFulcrum, Vuplex 3D WebView)
8+
- **Test login page rendering** with actual Passport authentication
9+
- **Evaluate message passing** between JavaScript and Unity
10+
- **Measure performance** (FPS, memory usage, rendering quality)
11+
- **Validate SDK integration** for distribution
12+
13+
## πŸ“ Structure
14+
15+
```
16+
WebViewTesting/
17+
β”œβ”€β”€ WebViewTestManager.cs # Main test controller
18+
β”œβ”€β”€ IWebViewAdapter.cs # Common interface for all WebView packages
19+
β”œβ”€β”€ AlacrityWebViewAdapter.cs # Alacrity WebView implementation
20+
β”œβ”€β”€ UWebView2Adapter.cs # UWebView2 implementation
21+
β”œβ”€β”€ ZenFulcrumWebViewAdapter.cs # ZenFulcrum implementation
22+
β”œβ”€β”€ Vuplex3DWebViewAdapter.cs # Vuplex 3D WebView implementation
23+
β”œβ”€β”€ WebViewTestSceneSetup.cs # Editor utility to create test scene
24+
└── README.md # This file
25+
```
26+
27+
## πŸš€ Quick Start
28+
29+
### 1. Create Test Scene
30+
31+
```csharp
32+
// In Unity Editor:
33+
Immutable β†’ WebView Testing β†’ Create WebView Test Scene
34+
```
35+
36+
### 2. Import WebView Package
37+
38+
Download and import one of the WebView packages:
39+
40+
- **Volt Unity Web Browser (UWB)**: `https://projects.voltstro.dev/UnityWebBrowser/latest/` ⭐ **RECOMMENDED** (MIT License, Multi-Platform)
41+
- **Alacrity**: `https://alacrity.kevinbedi.com/`
42+
- **UWebView2**: `https://uwebview.com/`
43+
- **ZenFulcrum**: `https://zenfulcrum.com/browser`
44+
- **Vuplex 3D WebView**: `https://store.vuplex.com/webview/windows-mac`
45+
46+
### 3. Update Adapter Implementation
47+
48+
Replace the template code in the corresponding adapter (e.g., `AlacrityWebViewAdapter.cs`) with actual WebView API calls.
49+
50+
### 4. Run Tests
51+
52+
1. Open the WebView Test scene
53+
2.
54+
3. Select the WebView package in the dropdown
55+
4. Click "Test Login Page" to test with `https://auth.immutable.com`
56+
5. Click "Test Messaging" to test JavaScript ↔ Unity communication
57+
58+
## πŸ§ͺ Test Scenarios
59+
60+
### Login Page Test
61+
62+
- βœ… **Load Passport login page** (`https://auth.immutable.com`)
63+
- βœ… **Render CSS3 features** (rounded corners, gradients, fonts)
64+
- βœ… **Interactive elements** (buttons, forms, dropdowns)
65+
- βœ… **OAuth flow handling** (redirects, callbacks)
66+
- βœ… **Performance monitoring** (FPS, memory usage)
67+
68+
### Message Passing Test
69+
70+
- βœ… **Unity β†’ JavaScript** communication
71+
- βœ… **JavaScript β†’ Unity** communication
72+
- βœ… **OAuth callback simulation**
73+
- βœ… **Performance data exchange**
74+
- βœ… **Error handling**
75+
76+
## πŸ“Š Evaluation Criteria
77+
78+
Rate each WebView package (1-5 stars):
79+
80+
| Criteria | Weight | Description |
81+
|----------|--------|-------------|
82+
| **Rendering Quality** | High | CSS3 support, font clarity, animations |
83+
| **Performance** | High | FPS, memory usage, startup time |
84+
| **Input Handling** | Medium | Mouse, keyboard responsiveness |
85+
| **Message Passing** | High | JavaScript ↔ Unity communication |
86+
| **Setup Complexity** | Medium | Import β†’ working in minutes |
87+
| **Documentation** | Low | Examples, API docs quality |
88+
| **Licensing Cost** | High | SDK distribution feasibility |
89+
| **Platform Support** | Medium | Windows, macOS, Linux |
90+
91+
## πŸ”§ Implementation Guide
92+
93+
### Adding a New WebView Package
94+
95+
1. **Create Adapter Class**:
96+
97+
```csharp
98+
public class MyWebViewAdapter : IWebViewAdapter
99+
{
100+
// Implement all interface methods
101+
}
102+
```
103+
104+
1. **Update WebViewTestManager**:
105+
106+
```csharp
107+
// Add to WebViewPackage enum
108+
public enum WebViewPackage
109+
{
110+
MyWebView // Add here
111+
}
112+
113+
// Add to CreateWebViewAdapter method
114+
case WebViewPackage.MyWebView:
115+
return new MyWebViewAdapter();
116+
```
117+
118+
1. **Test Implementation**:
119+
120+
- Run login page test
121+
- Verify message passing
122+
- Check performance metrics
123+
124+
### Message Passing Implementation
125+
126+
**JavaScript β†’ Unity**:
127+
128+
```javascript
129+
// In WebView
130+
window.unityInstance.SendMessage('WebViewTestManager', 'OnTestMessage', 'Hello Unity!');
131+
```
132+
133+
**Unity β†’ JavaScript**:
134+
135+
```csharp
136+
// In Unity
137+
webView.ExecuteJavaScript("window.receiveUnityMessage('Hello WebView!');");
138+
```
139+
140+
## πŸ“ Test Results Template
141+
142+
```markdown
143+
## WebView Package: [Package Name]
144+
145+
### Setup
146+
- **Import Time**: X minutes
147+
- **Complexity**: Easy/Medium/Hard
148+
- **Dependencies**: List any required dependencies
149+
150+
### Login Page Test
151+
- **Rendering Quality**: ⭐⭐⭐⭐⭐ (5/5)
152+
- **Load Time**: X seconds
153+
- **Interactive Elements**: Working/Broken
154+
- **CSS3 Support**: Full/Partial/None
155+
156+
### Performance
157+
- **Average FPS**: X fps
158+
- **Memory Usage**: X MB
159+
- **Startup Time**: X seconds
160+
161+
### Message Passing
162+
- **Unity β†’ JS**: Working/Broken
163+
- **JS β†’ Unity**: Working/Broken
164+
- **OAuth Simulation**: Working/Broken
165+
166+
### Licensing
167+
- **Cost**: $X or Free
168+
- **SDK Distribution**: Allowed/Restricted
169+
- **Commercial Use**: Allowed/Restricted
170+
171+
### Overall Rating: ⭐⭐⭐⭐⭐ (X/5)
172+
**Recommendation**: Use/Don't Use for SDK
173+
**Notes**: Additional observations...
174+
```
175+
176+
## πŸ”— Test Resources
177+
178+
- **Login Page**: `https://auth.immutable.com`
179+
- **Message Test Page**: `StreamingAssets/test-message-page.html`
180+
- **OAuth Callback**: `immutablerunner://callback?code=test&state=test`
181+
182+
## 🎯 Success Criteria
183+
184+
A WebView package is suitable for SDK distribution if:
185+
186+
1. βœ… **Renders login page correctly** (all elements visible and interactive)
187+
2. βœ… **Maintains 30+ FPS** during normal operation
188+
3. βœ… **Supports JavaScript ↔ Unity** message passing
189+
4. βœ… **Licensing allows SDK distribution** (free or reasonable cost)
190+
5. βœ… **Easy integration** (< 1 hour setup for developers)
191+
6. βœ… **Handles OAuth callbacks** properly
192+
193+
## 🚨 Known Issues
194+
195+
- **Template adapters** need actual WebView API implementation
196+
- **Message passing** methods vary between packages
197+
- **Performance metrics** may need package-specific implementation
198+
- **IL2CPP compatibility** should be tested for each package
199+
200+
## πŸ“ž Support
201+
202+
For questions about this testing framework:
203+
204+
1. Check the adapter implementation for your WebView package
205+
2. Review the test HTML page for message passing examples
206+
3. Consult the WebView package documentation
207+
4. Test with the actual Passport login page
208+
209+
---
210+
211+
**Happy Testing!** πŸ§ͺ✨

β€Žsample/Assets/Scripts/Passport/WebViewTesting/README.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
Β (0)