I am having a difficult time to get camera view to work with Navigation Drawer pattern. I load wikitude world in a separate fragment. NavigationDrawer works perfect. I load different layouts with my fragment successfully. As soon as I try loading wikitude Camera View application crash. I have downloaded a new SDK just today so I believe I am up to date.
Please advise me. I am getting this error message:
android.view.InflateException: Binary XML file line #6: Error inflating class com.wikitude.architect.ArchitectView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
I created a separate Fragment for Wikitude World:
"public class MyCameraViewFragment extends Fragment "
I do call all lifecycle methods but I think the code does not reach here:
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
@Override
public void onDetach() {
super.onDetach();
}
@Override
public void onResume() {
super.onResume();
if ( this.architectView != null ) {
// call mandatory live-cycle method of architectView
this.architectView.onResume();
}
}
@Override
public void onPause() {
super.onPause();
// call mandatory live-cycle method of architectView
if ( this.architectView != null ) {
this.architectView.onPause();
}
}
@Override
public void onStop() {
super.onStop();
}
@Override
public void onDestroy() {
super.onDestroy();
if ( this.architectView != null ) {
this.architectView.onDestroy();
}
}
@Override
public void onLowMemory() {
super.onLowMemory();
if ( this.architectView != null ) {
this.architectView.onLowMemory();
}
}
G
Gabriele Boccone
said
over 9 years ago
Hi, please check that the activity in your application is declared as "extends FragmentActivity" instead of "extends Activity", this could be a part of the problem if your application uses fragments.
S
Sergey.kargopolov
said
over 9 years ago
Gabriele, thank you very much for your response!
Yes. The main activity that creates fragments extends FragmentActivity
public class MainActivity extends FragmentActivity
If I load different layout.xml in MyCameraViewFragment. Then there is no exception and can switch between pages and load different layouts. As soon as I load xml file that holds ArchitectView, I start getting exception and application crashes.
Do you see what else can trigger the exception message mentioned above?
S
Sergey.kargopolov
said
over 9 years ago
Gabriele, I think I was able to reproduce the problem...
I have noticed another error message in log file. Please see below:
myapplication4.app D/ArchitectView? Exception while getting Camera Parameters
java.lang.RuntimeException: Fail to get camera info
at android.hardware.Camera._getCameraInfo(Native Method)
I was getting this error message even with proper permissions in AndroidManifest file... I restarted the device and it started working properly. The good news is that there is no problem with Fragments or Navigation Drawer now. It works stable until I turn off device screen with Camera View on. When I turn the screen back on my application crashes. And this happens consistently on Samsung Galazy Nexus Android 4.2.1 API 17 device... After it crashes a few times like this, then I need to restart device again because I start getting error message - "Exception while getting Camera Parameters" and of course application crashes with the same error message I created this Post with. It cannot inflate the architect world view....
I tried another device - HTC EVE 3D Android 4.0.3 API 15. My application behaves differently on this device. It never crashes when I turn off the device screen while the Camera View with Architect world is on. I tried many times turning off and on and it never crashes. This is a very good news. Navigation Drawer and fragements also work properly. The device is older, API is older but application works much stable.
Target images get recognized and image drawables(overlays) display well on either device.
However with the new Wikitude SDK for Android Video Drawable on ether device fail to play even if I use Wikitude App downloaded from Android play store. I have created architect world and loaded it on my server. Then I load it using the this.architectView.load("<URL TO AR WORLD ON MY SERVER>"); The same URL consistently works and all video drawables play well on iOS. But on Android video drawables fail to play in my app or in Wikitude App itself. I tried restarting My App, Wikitude App and restarting devices, I managed to play it only once on HTC EVE 3D device but after I restarted the App again I could not play it again. Please note, the same url to Architect world works consistently well and all video drawables play on iOS. I have also updated the iOS Wikidute SDK to a newer version today.
Please advise me how to fix these issues.
Below are the error messages that I get on either device when Architect World is loaded.
E/MediaPlayer? Error (1,-2147483648)
E/MediaPlayer? error (1, -2147483648)
W/System.err? java.lang.NullPointerException
W/System.err? at com.wikitude.architect.VideoManager.a(Unknown Source)
W/System.err? at com.wikitude.architect.ArchitectWebView.playVideoCallback(Unknown Source)
W/System.err? at com.wikitude.architect.PlatformBridge.callAsyncImpl(Native Method)
at com.wikitude.architect.PlatformBridge.callAsyncImpl(Unknown Source)
E/VideoManager? Exception when playing video null
Thank you very much and I hope for your support.
G
Gabriele Boccone
said
over 9 years ago
Hi, Sergey.
If you have problem when turning off and on the screen, then you should check that your Fragment also forwards the "onPause()"/"onResume()" events to the underlying ArchitectView. If the ArchitectView isn't paused when the application stops, this could cause the crash you are experiencing when resuming.
About the VideoDrawable, could it just be a video format compatibility issue? Did it also fail with the previous SDK release? Have you tried with another video? Could you please send the complete log of this error? It's very strange that you get a null pointer exception, are you sure that the video is loaded correctly? Maybe there is some problem loading the video, and the error is only a consequence of that?
S
Sergey.kargopolov
said
over 9 years ago
Gabriele, thank you for your reply. Yes, lifecycle methods get called. I double checked. When I turn off device screen it calles onPause(), when I turn it back on it calles onResume() and crashes then calles onPause() then calles onDestroy().
I am attaching here with this post a few files.
1. Log file taken from HTC EVO device Android 4.0.3 API 15. Application does not crash on this device but video drawables do not alway play. To get video drawables play I need to restart application a couple of times. Image drawables always work well.
2. Log file from Samsung Galaxy Nexus Android 4.2.1 API 17. Application crashes when creen goes off and then back on. The same story with video drawables. Image drawables always work well.
3. I am also attaching a MainActivity with two fragments declared in a single file.
4. A sample Navigation Drawer project with one MainActivity created in Android Studio.
Do you see where the problem is?
S
Sergey.kargopolov
said
over 9 years ago
Hi Gabriele!
Just wanted to learn if information I have attached in my post is sufficient and can help you to advise me on why video drawables most of the time fail to play on Android and why application crashes in Nexus Galaxy when screen is turned off and then back on?
Thank you Gabriele!
G
Gabriele Boccone
said
over 9 years ago
Hi.
Yes, Thank you for the information, I'm working on this issue.
G
Gabriele Boccone
said
over 9 years ago
Hi, I have found something about the VideoDrawable.
I see that you have disabled the 'onLoaded' trigger on all your videos. This means that a video can start playing before it's fully loaded. This could be an explanation for the issue you are experiencing.
Please enable the trigger (only play videos after you get the "onLoaded" event), and check again.
S
Sergey.kargopolov
said
over 9 years ago
Gabriele, thank you for your reply. I am not sure if I understood you right. Do you suggest that I should call play() inside of onLoaded()?
The goal is to play video as soon as target image is recognized. And here is how I do it. It works on iOS by the way.
var my_video = new AR.VideoDrawable(?<URL TO VIDEO FILE ON REMOTE SERVER>", 0.9, {
offsetX: 0,
offsetY: 0,
onLoaded: function videoLoaded() {
},
onPlaybackStarted: function videoPlaying () {
my_video.enabled = true;
},
onFinishedPlaying: function videoFinished () {
my_video.playing = false;
my_video.enabled = false;
},
onClick: function videoClicked () {
if (my_video.playing) {
my_video.pause();
my_video.playing = false;
} else {
my_video.resume();
my_video.playing = true;
}
}
});
var my_video_obj = new AR.Trackable2DObject(this.tracker, ?target_image_name", {
drawables: {
cam:
},
onEnterFieldOfVision: function onEnterFieldOfViewFn () {
my_video.play(1);
my_video.playing = true;
},
onExitFieldOfVision: function onExitFieldOfView() {
if (my_video.playing) {
my_video.stop();
my_video.playing = false;
}
}
});
I have tried playing video only after the onLoaded is called. It did not help.Ex.
var can_video_play = false;
... onLoaded: function videoLoaded() {
can_video_play = true;
}
?
onEnterFieldOfVision: function onEnterFieldOfViewFn () {
if(can_video_play)
{
my_video.play(1);
my_video.playing = true;
}
},
It still looks to me that the problem is on device side :(? I am getting errors in log file that I think are the cause of why videos are not playing?. In my previous post I have attached a sample application. Do not know if you have time to run it. I wonder if it runs on your side. If does not may be you will see why?
Why does it throw this message?:
called unimplemented OpenGL ES API
Or this one?:
MediaPlayer? error
04-08 18:02:54.086 3878-3878/com.my-company.myapplication4.app D/dalvikvm? Trying to load lib /data/data/com.my-company.myapplication4.app/libarchitect.so 0x41f95df8
04-08 18:02:54.485 3878-3878/com.my-company.myapplication4.app W/CapsuleAPI? Method WebSettingsClassic::setMediaPlaybackRequiresUserGesture not found, return TRUE, please check the API level table.
04-08 18:02:54.485 3878-3878/com.my-company.myapplication4.app W/CapsuleAPI? could not invoke method setMediaPlaybackRequiresUserGesture of class android.webkit.WebSettingsClassic
04-08 18:02:54.688 3878-3878/com.my-company.myapplication4.app I/Choreographer? Skipped 96 frames! The application may be doing too much work on its main thread.
04-08 18:02:54.805 3878-3906/com.my-company.myapplication4.app E/libEGL? called unimplemented OpenGL ES API
04-08 18:02:54.805 3878-3906/com.my-company.myapplication4.app E/libEGL? called unimplemented OpenGL ES API
The error you get is "E/VideoManager? Exception when playing video null"
This means that the media player cannot play the video, because there is no video. When you create a VideoDrawable, the video is not available until your application receives the "onLoaded()' event.
If you declare onLoaded as an empty function, your application doesn't know whether the video is loaded or not.
S
Sergey.kargopolov
said
over 9 years ago
Gabriele, thank you for your response.
I did try waiting until video is loaded but the issue is still there. Video does not appear and does not play... I have tried many times. It would work ones and then would never appear again... on iPhone though the video drawable appears right away and starts playing right away... As always I have tried on two different Android devices and the behaviour identical. Here is javascript example:
var is_video_loaded = false;
var my_video = new AR.VideoDrawable(" URL TO mp4 file here ?, 0.9, {
offsetX: 0,
offsetY: 0,
onLoaded: function videoLoaded() {
is_video_loaded = true;
},
onPlaybackStarted: function videoPlaying () {
my_video.enabled = true;
},
onFinishedPlaying: function videoFinished () {
my_video.playing = false;
my_video.enabled = false;
},
onClick: function videoClicked () {
if (my_video.playing) {
my_video.pause();
my_video.playing = false;
} else {
my_video.resume();
my_video.playing = true;
}
}
});
var video_tracker = new AR.Trackable2DObject(this.tracker, ?target_image?, {
drawables: {
cam:
},
onEnterFieldOfVision: function onEnterFieldOfViewFn () {
if(is_video_loaded)
{
my_video.play(1);
my_video.playing = true;
}
},
onExitFieldOfVision: function onExitFieldOfView() {
if (my_video.playing) {
my_video.stop();
my_video.playing = false;
}
}
});
Gabriele, is there a way for me to trigger video loading again? I am assuming that for some reason the video loading takes a very long time or for some reason it is not loaded when was first requested. Can I trigger the system to make it try to load video one more time?
G
Gabriele Boccone
said
over 9 years ago
I checked your project and done some other test.
If I start your AR world in our sample application, then both videos are showing most of the times, but I've managed to reproduce the issue (although the error message on my test device is different), and we are working on a possible solution.
We will keep you informed about the development.
S
Sergey.kargopolov
said
over 9 years ago
Thank you very much Gabriele! Thank you for finding some time to check my sample project and the AR world. I am very happy you were able to reproduce the issue because now I know you will fix it. How long do you think we will need to wait for the fix? Is it realistic to expect it next week?
Sergey.kargopolov